5 #ifndef __IRR_POINT_2D_H_INCLUDED__ 6 #define __IRR_POINT_2D_H_INCLUDED__ 68 bool operator<=(const vector2d<T>&other)
const 82 bool operator<(const vector2d<T>&other)
const 126 return X*other.X +
Y*other.Y;
154 const f64 cs = cos(degrees);
155 const f64 sn = sin(degrees);
160 set((T)(
X*cs -
Y*sn), (T)(
X*sn +
Y*cs));
188 return X < 0 ? 180 : 0;
191 return Y < 0 ? 270 : 90;
211 return X < 0 ? 180 : 0;
213 return Y < 0 ? 90 : 270;
251 return atan(sqrt(1 - tmp*tmp) / tmp) *
RADTODEG64;
261 if (begin.X != end.X)
263 return ((begin.X <=
X &&
X <= end.X) ||
264 (begin.X >=
X &&
X >= end.X));
268 return ((begin.Y <=
Y &&
Y <= end.Y) ||
269 (begin.Y >=
Y &&
Y >= end.Y));
281 return vector2d<T>((T)(other.X*inv +
X*d), (T)(other.Y*inv +
Y*d));
293 const f64 inv = 1.0f - d;
294 const f64 mul0 = inv * inv;
295 const f64 mul1 = 2.0f * d * inv;
296 const f64 mul2 = d * d;
298 return vector2d<T> ( (T)(
X * mul0 + v2.X * mul1 + v3.X * mul2),
299 (T)(
Y * mul0 + v2.Y * mul1 + v3.Y * mul2));
310 X = (T)((
f64)b.X + ( ( a.X - b.X ) * d ));
311 Y = (T)((
f64)b.Y + ( ( a.Y - b.Y ) * d ));
328 template<
class S,
class T>
const f64 RADTODEG64
64bit constant for converting from radians to degrees
vector2d< T > operator-(const T v) const
vector2d< T > operator-() const
dimension2d()
Default constructor for empty dimension.
vector2d< T > operator-(const vector2d< T > &other) const
float f32
32 bit floating point variable.
REALINLINE f32 squareroot(const f32 f)
T Y
Y coordinate of vector.
vector2d< T > & rotateBy(f64 degrees, const vector2d< T > ¢er=vector2d< T >())
rotates the point anticlockwise around a center by an amount of degrees.
vector2d< T > & operator=(const vector2d< T > &other)
Everything in the Irrlicht Engine can be found in this namespace.
vector2d< T > getInterpolated_quadratic(const vector2d< T > &v2, const vector2d< T > &v3, f64 d) const
Creates a quadratically interpolated vector between this and two other vectors.
vector2d< T > operator*(const T v) const
bool operator!=(const vector2d< T > &other) const
f64 getAngleWith(const vector2d< T > &b) const
Calculates the angle between this vector and another one in degree.
Specifies a 2 dimensional size.
double f64
64 bit floating point variable.
vector2d(const dimension2d< T > &other)
vector2d(T nx, T ny)
Constructor with two different values.
vector2d< T > getInterpolated(const vector2d< T > &other, f64 d) const
Creates an interpolated vector between this vector and another vector.
vector2d< T > & operator+=(const dimension2d< T > &other)
const f64 DEGTORAD64
64bit constant for converting from degrees to radians (formally known as GRAD_PI2) ...
vector2d()
Default constructor (null vector)
bool operator==(const vector2d< T > &other) const
vector2d< T > operator-(const dimension2d< T > &other) const
vector2d< T > & operator*=(const T v)
f64 getAngle() const
Calculates the angle of this vector in degrees in the counter trigonometric sense.
vector2d< T > operator/(const vector2d< T > &other) const
vector2d< T > operator+(const vector2d< T > &other) const
vector2d< T > & normalize()
Normalize the vector.
T getLength() const
Gets the length of the vector.
T Width
Width of the dimension.
vector2d< T > & interpolate(const vector2d< T > &a, const vector2d< T > &b, f64 d)
Sets this vector to the linearly interpolated vector between a and b.
T dotProduct(const vector2d< T > &other) const
Get the dot product of this vector with another.
vector2d< T > & operator+=(const vector2d< T > &other)
T getDistanceFromSQ(const vector2d< T > &other) const
Returns squared distance from another point.
vector2d< T > & operator-=(const dimension2d< T > &other)
vector2d(T n)
Constructor with the same value for both members.
vector2d(const vector2d< T > &other)
Copy constructor.
vector2d< T > & operator-=(const vector2d< T > &other)
vector2d< T > operator+(const T v) const
bool equals(const vector2d< T > &other) const
Checks if this vector equals the other one.
vector2d< T > & operator/=(const T v)
f64 getAngleTrig() const
Calculates the angle of this vector in degrees in the trigonometric sense.
2d vector template class with lots of operators and methods.
bool isBetweenPoints(const vector2d< T > &begin, const vector2d< T > &end) const
Returns if this vector interpreted as a point is on a line between two other points.
vector2d< T > operator*(const vector2d< T > &other) const
vector2d< T > & operator+=(const T v)
vector2d< T > & operator-=(const T v)
vector2d< T > & operator*=(const vector2d< T > &other)
vector2d< T > operator+(const dimension2d< T > &other) const
T Height
Height of the dimension.
bool equals(const f64 a, const f64 b, const f64 tolerance=ROUNDING_ERROR_f64)
returns if a equals b, taking possible rounding errors into account
vector2d< T > operator/(const T v) const
bool operator>(const vector2d< T > &other) const
sort in order X, Y. Difference must be above rounding tolerance.
REALINLINE f64 reciprocal_squareroot(const f64 x)
vector2d< T > & operator/=(const vector2d< T > &other)
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
vector2d< s32 > vector2di
Typedef for integer 2d vector.
vector2d< T > & operator=(const dimension2d< T > &other)
vector2d< f32 > vector2df
Typedef for f32 2d vector.
T X
X coordinate of vector.
T getLengthSQ() const
Get the squared length of this vector.
T getDistanceFrom(const vector2d< T > &other) const
Gets distance from another point.
bool operator>=(const vector2d< T > &other) const
sort in order X, Y. Equality with rounding tolerance.