|
@@ -30,10 +30,10 @@ struct vec2
|
|
|
this->x -= v.x;
|
|
|
this->y -= v.y;
|
|
|
};
|
|
|
- void scale(const float v)
|
|
|
+ void scale(const double n)
|
|
|
{
|
|
|
- this->x *= v;
|
|
|
- this->y *= v;
|
|
|
+ this->x *= n;
|
|
|
+ this->y *= n;
|
|
|
};
|
|
|
vec2 rotate(const double angle) const
|
|
|
{
|
|
@@ -87,6 +87,73 @@ struct vec2
|
|
|
/* return the imaginary Z component */
|
|
|
return (this->x * v.y) - (this->y * v.x);
|
|
|
};
|
|
|
+
|
|
|
+ vec2 & operator = (const vec2 &v)
|
|
|
+ {
|
|
|
+ this->x = v.x;
|
|
|
+ this->y = v.y;
|
|
|
+ return *this;
|
|
|
+ };
|
|
|
+ bool operator == (const vec2 &v) const
|
|
|
+ {
|
|
|
+ return (this->x == v.x) && (this->y == v.y);
|
|
|
+ };
|
|
|
+ bool operator != (const vec2 &v) const
|
|
|
+ {
|
|
|
+ return (this->x != v.x) || (this->y != v.y);
|
|
|
+ };
|
|
|
+
|
|
|
+ vec2 operator + (const vec2 &v) const
|
|
|
+ {
|
|
|
+ return vec2(this->x + v.x,
|
|
|
+ this->y + v.y);
|
|
|
+ }
|
|
|
+ vec2 operator - (const vec2 &v) const
|
|
|
+ {
|
|
|
+ return vec2(this->x - v.x,
|
|
|
+ this->y - v.y);
|
|
|
+ };
|
|
|
+ vec2 operator * (const double n) const
|
|
|
+ {
|
|
|
+ return vec2(this->x * n,
|
|
|
+ this->y * n);
|
|
|
+ };
|
|
|
+ vec2 operator / (const double n) const
|
|
|
+ {
|
|
|
+ return vec2(this->x / n,
|
|
|
+ this->y / n);
|
|
|
+ };
|
|
|
+ vec2 operator - ()
|
|
|
+ {
|
|
|
+ return vec2(-this->x,
|
|
|
+ -this->y);
|
|
|
+ };
|
|
|
+
|
|
|
+ vec2 & operator += (const vec2 &v)
|
|
|
+ {
|
|
|
+ this->x += v.x;
|
|
|
+ this->y += v.y;
|
|
|
+ return *this;
|
|
|
+ };
|
|
|
+ vec2 & operator -= (const vec2 &v)
|
|
|
+ {
|
|
|
+ this->x -= v.x;
|
|
|
+ this->y -= v.y;
|
|
|
+ return *this;
|
|
|
+ }
|
|
|
+ vec2 & operator *= (const double n)
|
|
|
+ {
|
|
|
+ this->x *= n;
|
|
|
+ this->y *= n;
|
|
|
+ return *this;
|
|
|
+ }
|
|
|
+ vec2 & operator /= (const double n)
|
|
|
+ {
|
|
|
+ this->x /= n;
|
|
|
+ this->y /= n;
|
|
|
+ return *this;
|
|
|
+ }
|
|
|
+
|
|
|
};
|
|
|
|
|
|
#endif /* PHYSICENGINE_VEC2_H */
|