Browse Source

Point: Add operator* float and operator-

pull/2004/head
obligaron 5 years ago committed by Anders Jenbo
parent
commit
be13a0f727
  1. 21
      Source/engine.h

21
Source/engine.h

@ -91,6 +91,13 @@ struct Point {
return *this;
}
Point &operator*=(const float factor)
{
x *= factor;
y *= factor;
return *this;
}
friend Point operator+(Point a, const Point &b)
{
a += b;
@ -103,6 +110,20 @@ struct Point {
return a;
}
friend Point operator-(const Point &a)
{
Point b;
b.x = -a.x;
b.y = -a.y;
return b;
}
friend Point operator*(Point a, const float factor)
{
a *= factor;
return a;
}
/**
* @brief Fast approximate distance between two points, using only integer arithmetic, with less than ~5% error
* @param other Pointer to which we want the distance

Loading…
Cancel
Save