2d vector template class with lots of operators and methods. More...
#include <vector2d.h>
Public Member Functions | |
vector2d () | |
Default constructor (null vector) | |
vector2d (const dimension2d< T > &other) | |
vector2d (const vector2d< T > &other) | |
Copy constructor. | |
vector2d (T n) | |
Constructor with the same value for both members. | |
vector2d (T nx, T ny) | |
Constructor with two different values. | |
T | dotProduct (const vector2d< T > &other) const |
Get the dot product of this vector with another. | |
bool | equals (const vector2d< T > &other) const |
Checks if this vector equals the other one. | |
f64 | getAngle () const |
Calculates the angle of this vector in degrees in the counter trigonometric sense. | |
f64 | getAngleTrig () const |
Calculates the angle of this vector in degrees in the trigonometric sense. | |
f64 | getAngleWith (const vector2d< T > &b) const |
Calculates the angle between this vector and another one in degree. | |
T | getDistanceFrom (const vector2d< T > &other) const |
Gets distance from another point. | |
T | getDistanceFromSQ (const vector2d< T > &other) const |
Returns squared distance from another point. | |
vector2d< T > | getInterpolated (const vector2d< T > &other, f64 d) const |
Creates an interpolated vector between this vector and another vector. | |
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. | |
T | getLength () const |
Gets the length of the vector. | |
T | getLengthSQ () const |
Get the squared length of this vector. | |
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. | |
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 > & | normalize () |
Normalize the vector. | |
bool | operator!= (const vector2d< T > &other) const |
vector2d< T > | operator* (const T v) const |
vector2d< T > | operator* (const vector2d< T > &other) const |
vector2d< T > & | operator*= (const T v) |
vector2d< T > & | operator*= (const vector2d< T > &other) |
vector2d< T > | operator+ (const dimension2d< T > &other) const |
vector2d< T > | operator+ (const T v) const |
vector2d< T > | operator+ (const vector2d< T > &other) const |
vector2d< T > & | operator+= (const dimension2d< T > &other) |
vector2d< T > & | operator+= (const T v) |
vector2d< T > & | operator+= (const vector2d< T > &other) |
vector2d< T > | operator- () const |
vector2d< T > | operator- (const dimension2d< T > &other) const |
vector2d< T > | operator- (const T v) const |
vector2d< T > | operator- (const vector2d< T > &other) const |
vector2d< T > & | operator-= (const dimension2d< T > &other) |
vector2d< T > & | operator-= (const T v) |
vector2d< T > & | operator-= (const vector2d< T > &other) |
vector2d< T > | operator/ (const T v) const |
vector2d< T > | operator/ (const vector2d< T > &other) const |
vector2d< T > & | operator/= (const T v) |
vector2d< T > & | operator/= (const vector2d< T > &other) |
bool | operator< (const vector2d< T > &other) const |
sort in order X, Y. Difference must be above rounding tolerance. | |
bool | operator<= (const vector2d< T > &other) const |
sort in order X, Y. Equality with rounding tolerance. | |
vector2d< T > & | operator= (const dimension2d< T > &other) |
vector2d< T > & | operator= (const vector2d< T > &other) |
bool | operator== (const vector2d< T > &other) const |
bool | operator> (const vector2d< T > &other) const |
sort in order X, Y. Difference must be above rounding tolerance. | |
bool | operator>= (const vector2d< T > &other) const |
sort in order X, Y. Equality with rounding tolerance. | |
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 > & | set (const vector2d< T > &p) |
vector2d< T > & | set (T nx, T ny) |
Public Attributes | |
T | X |
X coordinate of vector. | |
T | Y |
Y coordinate of vector. | |
2d vector template class with lots of operators and methods.
As of Irrlicht 1.6, this class supercedes position2d, which should be considered deprecated.
Definition at line 21 of file vector2d.h.
|
inline |
Default constructor (null vector)
Definition at line 25 of file vector2d.h.
Constructor with two different values.
Definition at line 27 of file vector2d.h.
|
inlineexplicit |
Constructor with the same value for both members.
Definition at line 29 of file vector2d.h.
Copy constructor.
Definition at line 31 of file vector2d.h.
|
inline |
Definition at line 33 of file vector2d.h.
Get the dot product of this vector with another.
other | Other vector to take dot product with. |
Definition at line 124 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Referenced by irr::core::line2d< T >::getClosestPoint().
Checks if this vector equals the other one.
Takes floating point rounding errors into account.
other | Vector to compare with. |
Definition at line 104 of file vector2d.h.
References irr::core::equals(), irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Referenced by irr::core::vector2d< T >::operator!=(), and irr::core::vector2d< T >::operator==().
|
inline |
Calculates the angle of this vector in degrees in the counter trigonometric sense.
0 is to the right (3 o'clock), values increase clockwise.
Definition at line 208 of file vector2d.h.
References irr::core::clamp(), irr::core::RADTODEG64, irr::core::squareroot(), irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
|
inline |
Calculates the angle of this vector in degrees in the trigonometric sense.
0 is to the right (3 o'clock), values increase counter-clockwise. This method has been suggested by Pr3t3nd3r.
Definition at line 185 of file vector2d.h.
References irr::core::RADTODEG64, irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Calculates the angle between this vector and another one in degree.
b | Other vector to test with. |
Definition at line 238 of file vector2d.h.
References irr::core::RADTODEG64, irr::core::squareroot(), irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Gets distance from another point.
Here, the vector is interpreted as a point in 2-dimensional space.
other | Other vector to measure from. |
Definition at line 133 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Returns squared distance from another point.
Here, the vector is interpreted as a point in 2-dimensional space.
other | Other vector to measure from. |
Definition at line 142 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
|
inline |
Creates an interpolated vector between this vector and another vector.
other | The other vector to interpolate with. |
d | Interpolation value between 0.0f (all the other vector) and 1.0f (all this vector). Note that this is the opposite direction of interpolation to getInterpolated_quadratic() |
Definition at line 278 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Referenced by irr::video::S3DVertex::getInterpolated(), irr::video::S3DVertex2TCoords::getInterpolated(), and irr::video::S3DVertexTangents::getInterpolated().
|
inline |
Creates a quadratically interpolated vector between this and two other vectors.
v2 | Second vector to interpolate with. |
v3 | Third vector to interpolate with (maximum at 1.0f) |
d | Interpolation value between 0.0f (all this vector) and 1.0f (all the 3rd vector). Note that this is the opposite direction of interpolation to getInterpolated() and interpolate() |
Definition at line 290 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
|
inline |
Gets the length of the vector.
Definition at line 114 of file vector2d.h.
References irr::core::squareroot(), irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Referenced by irr::core::line2d< T >::getClosestPoint().
|
inline |
Get the squared length of this vector.
This is useful because it is much faster than getLength().
Definition at line 119 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
|
inline |
Sets this vector to the linearly interpolated vector between a and b.
a | first vector to interpolate with, maximum at 1.0f |
b | second vector to interpolate with, maximum at 0.0f |
d | Interpolation value between 0.0f (all vector b) and 1.0f (all vector a) Note that this is the opposite direction of interpolation to getInterpolated_quadratic() |
Definition at line 308 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
|
inline |
Returns if this vector interpreted as a point is on a line between two other points.
It is assumed that the point is on the line.
begin | Beginning vector to compare between. |
end | Ending vector to compare between. |
Definition at line 259 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Normalize the vector.
The null vector is left untouched.
Definition at line 170 of file vector2d.h.
References irr::core::reciprocal_squareroot(), irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 96 of file vector2d.h.
References irr::core::vector2d< T >::equals().
Definition at line 59 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 57 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 60 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 58 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
|
inline |
Definition at line 44 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 46 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 43 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
|
inline |
Definition at line 48 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 47 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 45 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 37 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
|
inline |
Definition at line 51 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 53 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 50 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
|
inline |
Definition at line 55 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 54 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 52 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 64 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 62 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 65 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 63 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
sort in order X, Y. Difference must be above rounding tolerance.
Definition at line 82 of file vector2d.h.
References irr::core::equals(), irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
sort in order X, Y. Equality with rounding tolerance.
Definition at line 68 of file vector2d.h.
References irr::core::equals(), irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
|
inline |
Definition at line 41 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 39 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 95 of file vector2d.h.
References irr::core::vector2d< T >::equals().
sort in order X, Y. Difference must be above rounding tolerance.
Definition at line 89 of file vector2d.h.
References irr::core::equals(), irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
sort in order X, Y. Equality with rounding tolerance.
Definition at line 75 of file vector2d.h.
References irr::core::equals(), irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
|
inline |
rotates the point anticlockwise around a center by an amount of degrees.
degrees | Amount of degrees to rotate by, anticlockwise. |
center | Rotation center. |
Definition at line 151 of file vector2d.h.
References irr::core::DEGTORAD64, irr::core::vector2d< T >::set(), irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 110 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Definition at line 109 of file vector2d.h.
References irr::core::vector2d< T >::X, and irr::core::vector2d< T >::Y.
Referenced by irr::core::vector2d< T >::rotateBy().
T irr::core::vector2d< T >::X |
X coordinate of vector.
Definition at line 316 of file vector2d.h.
Referenced by irr::core::CMatrix4< T >::buildTextureTransform(), irr::core::vector2d< T >::dotProduct(), irr::core::vector2d< T >::equals(), irr::core::vector2d< T >::getAngle(), irr::core::vector2d< T >::getAngleTrig(), irr::core::vector2d< T >::getAngleWith(), irr::core::vector2d< T >::getDistanceFrom(), irr::core::vector2d< T >::getDistanceFromSQ(), irr::core::vector2d< T >::getInterpolated(), irr::core::vector2d< T >::getInterpolated_quadratic(), irr::core::vector2d< T >::getLength(), irr::core::vector2d< T >::getLengthSQ(), irr::core::vector2d< T >::interpolate(), irr::core::vector2d< T >::isBetweenPoints(), irr::core::vector2d< T >::normalize(), irr::core::vector2d< T >::operator*(), irr::core::vector2d< T >::operator*(), irr::core::vector2d< T >::operator*=(), irr::core::vector2d< T >::operator*=(), irr::core::vector2d< T >::operator+(), irr::core::vector2d< T >::operator+(), irr::core::vector2d< T >::operator+(), irr::core::vector2d< T >::operator+=(), irr::core::vector2d< T >::operator+=(), irr::core::vector2d< T >::operator+=(), irr::core::vector2d< T >::operator-(), irr::core::vector2d< T >::operator-(), irr::core::vector2d< T >::operator-(), irr::core::vector2d< T >::operator-(), irr::core::vector2d< T >::operator-=(), irr::core::vector2d< T >::operator-=(), irr::core::vector2d< T >::operator-=(), irr::core::vector2d< T >::operator/(), irr::core::vector2d< T >::operator/(), irr::core::vector2d< T >::operator/=(), irr::core::vector2d< T >::operator/=(), irr::core::vector2d< T >::operator<(), irr::core::vector2d< T >::operator<=(), irr::core::vector2d< T >::operator=(), irr::core::vector2d< T >::operator=(), irr::core::vector2d< T >::operator>(), irr::core::vector2d< T >::operator>=(), irr::core::vector2d< T >::rotateBy(), irr::core::vector2d< T >::set(), and irr::core::vector2d< T >::set().
T irr::core::vector2d< T >::Y |
Y coordinate of vector.
Definition at line 319 of file vector2d.h.
Referenced by irr::core::CMatrix4< T >::buildTextureTransform(), irr::core::vector2d< T >::dotProduct(), irr::core::vector2d< T >::equals(), irr::core::vector2d< T >::getAngle(), irr::core::vector2d< T >::getAngleTrig(), irr::core::vector2d< T >::getAngleWith(), irr::core::vector2d< T >::getDistanceFrom(), irr::core::vector2d< T >::getDistanceFromSQ(), irr::core::vector2d< T >::getInterpolated(), irr::core::vector2d< T >::getInterpolated_quadratic(), irr::core::vector2d< T >::getLength(), irr::core::vector2d< T >::getLengthSQ(), irr::core::vector2d< T >::interpolate(), irr::core::vector2d< T >::isBetweenPoints(), irr::core::vector2d< T >::normalize(), irr::core::vector2d< T >::operator*(), irr::core::vector2d< T >::operator*(), irr::core::vector2d< T >::operator*=(), irr::core::vector2d< T >::operator*=(), irr::core::vector2d< T >::operator+(), irr::core::vector2d< T >::operator+(), irr::core::vector2d< T >::operator+(), irr::core::vector2d< T >::operator+=(), irr::core::vector2d< T >::operator+=(), irr::core::vector2d< T >::operator+=(), irr::core::vector2d< T >::operator-(), irr::core::vector2d< T >::operator-(), irr::core::vector2d< T >::operator-(), irr::core::vector2d< T >::operator-(), irr::core::vector2d< T >::operator-=(), irr::core::vector2d< T >::operator-=(), irr::core::vector2d< T >::operator-=(), irr::core::vector2d< T >::operator/(), irr::core::vector2d< T >::operator/(), irr::core::vector2d< T >::operator/=(), irr::core::vector2d< T >::operator/=(), irr::core::vector2d< T >::operator<(), irr::core::vector2d< T >::operator<=(), irr::core::vector2d< T >::operator=(), irr::core::vector2d< T >::operator=(), irr::core::vector2d< T >::operator>(), irr::core::vector2d< T >::operator>=(), irr::core::vector2d< T >::rotateBy(), irr::core::vector2d< T >::set(), and irr::core::vector2d< T >::set().