5 #ifndef __IRR_POINT_2D_H_INCLUDED__ 6 #define __IRR_POINT_2D_H_INCLUDED__ 141 return X*other.X +
Y*other.Y;
155 (
X*other.X +
Y*other.Y) != 0;
183 const f64 cs = cos(degrees);
184 const f64 sn = sin(degrees);
189 set((T)(
X*cs -
Y*sn), (T)(
X*sn +
Y*cs));
217 return X < 0 ? 180 : 0;
220 return Y < 0 ? 270 : 90;
240 return X < 0 ? 180 : 0;
242 return Y < 0 ? 90 : 270;
280 return atan(sqrt(1 - tmp*tmp) / tmp) *
RADTODEG64;
299 if (begin.X !=
end.X)
301 return ((begin.X <=
X &&
X <=
end.X) ||
302 (begin.X >=
X &&
X >=
end.X));
306 return ((begin.Y <=
Y &&
Y <=
end.Y) ||
307 (begin.Y >=
Y &&
Y >=
end.Y));
318 const f64 inv = 1.0f - d;
319 return vector2d<T>((T)(other.X*inv +
X*d), (T)(other.Y*inv +
Y*d));
331 const f64 inv = 1.0f - d;
332 const f64 mul0 = inv * inv;
333 const f64 mul1 = 2.0f * d * inv;
334 const f64 mul2 = d * d;
337 (T)(
Y * mul0 +
v2.Y * mul1 +
v3.Y * mul2));
356 T
val = (
b.Y -
Y) * (
c.X -
b.X) -
357 (
b.X -
X) * (
c.Y -
b.Y);
359 if (
val == 0)
return 0;
361 return (
val > 0) ? 1 : 2;
367 T
val = (
b.Y -
Y) * (
c.X -
b.X) -
368 (
b.X -
X) * (
c.Y -
b.Y);
376 T
val = (
b.Y -
Y) * (
c.X -
b.X) -
377 (
b.X -
X) * (
c.Y -
b.Y);
390 X = (T)((
f64)
b.X + ( (
a.X -
b.X ) * d ));
391 Y = (T)((
f64)
b.Y + ( (
a.Y -
b.Y ) * d ));
408 template<
class S,
class T>
bool operator<(const vector2d< T > &other) const
sort in order X, Y. Difference must be above rounding tolerance.
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 > & set(T nx, T ny)
s32 checkOrientation(const vector2d< T > &b, const vector2d< T > &c) const
vector2d< T > operator-(const vector2d< T > &other) const
float f32
32 bit floating point variable.
T & operator [](u32 index)
REALINLINE f32 squareroot(const f32 f)
T Y
Y coordinate of vector.
vector2d< T > operator *(const vector2d< T > &other) const
vector2d< T > & set(const vector2d< T > &p)
bool areClockwise(const vector2d< T > &b, const vector2d< T > &c) const
bool equalsRelative(const T a, const T b, const T factor=relativeErrorFactor< T >())
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.
GLfloat GLfloat GLfloat v2
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.
bool nearlyParallel(const vector2d< T > &other, const T factor=relativeErrorFactor< T >()) const
check if this vector is parallel to another vector
double f64
64 bit floating point variable.
vector2d(const dimension2d< T > &other)
bool equals(const vector2d< T > &other, const T tolerance=(T) ROUNDING_ERROR_f32) const
Checks if this vector equals the other one.
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)
const f32 ROUNDING_ERROR_f32
CMatrix4< T > operator *(const T scalar, const CMatrix4< T > &mat)
vector2d()
Default constructor (null vector)
GLfloat GLfloat GLfloat GLfloat v3
bool operator==(const vector2d< T > &other) const
bool equals(const T a, const T b, const T tolerance=roundingError< T >())
returns if a equals b, taking possible rounding errors into account
vector2d< T > operator-(const dimension2d< T > &other) const
signed int s32
32 bit signed variable.
bool operator<=(const vector2d< T > &other) const
sort in order X, Y. Equality with rounding tolerance.
bool operator==(const CustomAllocator< T > &, const CustomAllocator< U > &)
unsigned int u32
32 bit unsigned variable.
vector2d< T > & operator *=(const vector2d< T > &other)
f64 getAngle() const
Calculates the angle of this vector in degrees in the counter trigonometric sense.
vector2d< T > operator/(const vector2d< T > &other) const
#define _IRR_DEBUG_BREAK_IF(_CONDITION_)
define a break macro for debugging.
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
vector2d< T > & operator/=(const T v)
f64 getAngleTrig() const
Calculates the angle of this vector in degrees in the trigonometric sense.
bool areCounterClockwise(const vector2d< T > &b, const vector2d< T > &c) const
GLboolean GLboolean GLboolean b
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 T v)
vector2d< T > & operator-=(const T v)
vector2d< T > operator+(const dimension2d< T > &other) const
GLboolean GLboolean GLboolean GLboolean a
T Height
Height of the dimension.
const T & operator [](u32 index) const
GLuint GLsizei GLsizei * length
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.