1.2 Math

You can do math with Vec2, just as you can with plain numbers. It is possible to assign x and y values directly, but you can also do math with the class itself. In this case the operator will be applied to x as well as y:

 
Vec2 p1(0.1,  0.3); 
Vec2 p2(0.3, -0.1); 
Vec2 p3 = p1 + p2;  // x: 0.4 , y: 0.2 
p3 -= 0.1;          // x: 0.3 , y: 0.1 
5p3 *= 2;            // x: 0.6 , y: 0.2 
p3 = p1 / 2.f;      // x: 0.05, y: 0.15