arsa
2.7
|
3d vector template class with lots of operators and methods. More...
#include <vector3d.h>
Public Member Functions | |
vector3d () | |
Default constructor (null vector). More... | |
vector3d (T nx, T ny, T nz) | |
Constructor with three different values. More... | |
vector3d (T n) | |
Constructor with the same value for all elements. More... | |
vector3d (const vector3d< T > &other) | |
Copy constructor. More... | |
vector3d< T > | operator- () const |
vector3d< T > & | operator= (const vector3d< T > &other) |
vector3d< T > | operator+ (const vector3d< T > &other) const |
vector3d< T > & | operator+= (const vector3d< T > &other) |
vector3d< T > | operator+ (const T val) const |
vector3d< T > & | operator+= (const T val) |
vector3d< T > | operator- (const vector3d< T > &other) const |
vector3d< T > & | operator-= (const vector3d< T > &other) |
vector3d< T > | operator- (const T val) const |
vector3d< T > & | operator-= (const T val) |
vector3d< T > | operator * (const vector3d< T > &other) const |
vector3d< T > & | operator *= (const vector3d< T > &other) |
vector3d< T > | operator * (const T v) const |
vector3d< T > & | operator *= (const T v) |
vector3d< T > | operator/ (const vector3d< T > &other) const |
vector3d< T > & | operator/= (const vector3d< T > &other) |
vector3d< T > | operator/ (const T v) const |
vector3d< T > & | operator/= (const T v) |
T & | operator [] (u32 index) |
const T & | operator [] (u32 index) const |
bool | operator<= (const vector3d< T > &other) const |
sort in order X, Y, Z. Equality with rounding tolerance. More... | |
bool | operator>= (const vector3d< T > &other) const |
sort in order X, Y, Z. Equality with rounding tolerance. More... | |
bool | operator< (const vector3d< T > &other) const |
sort in order X, Y, Z. Difference must be above rounding tolerance. More... | |
bool | operator> (const vector3d< T > &other) const |
sort in order X, Y, Z. Difference must be above rounding tolerance. More... | |
bool | operator== (const vector3d< T > &other) const |
use weak float compare More... | |
bool | operator!= (const vector3d< T > &other) const |
bool | equals (const vector3d< T > &other, const T tolerance=(T) ROUNDING_ERROR_f32) const |
returns if this vector equals the other one, taking floating point rounding errors into account More... | |
vector3d< T > & | set (const T nx, const T ny, const T nz) |
vector3d< T > & | set (const vector3d< T > &p) |
T | getLength () const |
Get length of the vector. More... | |
T | getLengthSQ () const |
Get squared length of the vector. More... | |
T | dotProduct (const vector3d< T > &other) const |
Get the dot product with another vector. More... | |
T | getDistanceFrom (const vector3d< T > &other) const |
Get distance from another point. More... | |
T | getDistanceFromSQ (const vector3d< T > &other) const |
Returns squared distance from another point. More... | |
vector3d< T > | crossProduct (const vector3d< T > &p) const |
Calculates the cross product with another vector. More... | |
bool | isBetweenPoints (const vector3d< T > &begin, const vector3d< T > &end) const |
Returns if this vector interpreted as a point is on a line between two other points. More... | |
vector3d< T > & | normalize () |
Normalizes the vector. More... | |
vector3d< T > & | setLength (T newlength) |
Sets the length of the vector to a new value. More... | |
vector3d< T > & | invert () |
Inverts the vector. More... | |
void | rotateXZBy (f64 degrees, const vector3d< T > ¢er=vector3d< T >()) |
Rotates the vector by a specified number of degrees around the Y axis and the specified center. More... | |
void | rotateXYBy (f64 degrees, const vector3d< T > ¢er=vector3d< T >()) |
Rotates the vector by a specified number of degrees around the Z axis and the specified center. More... | |
void | rotateYZBy (f64 degrees, const vector3d< T > ¢er=vector3d< T >()) |
Rotates the vector by a specified number of degrees around the X axis and the specified center. More... | |
vector3d< T > | getInterpolated (const vector3d< T > &other, f64 d) const |
Creates an interpolated vector between this vector and another vector. More... | |
vector3d< T > | getInterpolated_quadratic (const vector3d< T > &v2, const vector3d< T > &v3, f64 d) const |
Creates a quadratically interpolated vector between this and two other vectors. More... | |
vector3d< T > & | interpolate (const vector3d< T > &a, const vector3d< T > &b, f64 d) |
Sets this vector to the linearly interpolated vector between a and b. More... | |
vector3d< T > | getHorizontalAngle () const |
Get the rotations that would make a (0,0,1) direction vector point in the same direction as this direction vector. More... | |
vector3d< T > | getSphericalCoordinateAngles () const |
Get the spherical coordinate angles. More... | |
vector3d< T > | rotationToDirection (const vector3d< T > &forwards=vector3d< T >(0, 0, 1)) const |
Builds a direction vector from (this) rotation vector. More... | |
void | getAs4Values (T *array) const |
Fills an array of 4 values with the vector data (usually floats). More... | |
void | getAs3Values (T *array) const |
Fills an array of 3 values with the vector data (usually floats). More... | |
template<> | |
vector3d< s32 > | operator/ (s32 val) const |
partial specialization for integer vectors More... | |
template<> | |
vector3d< s32 > & | operator/= (s32 val) |
template<> | |
vector3d< s32 > | getSphericalCoordinateAngles () const |
Public Attributes | |
T | X |
X coordinate of the vector. More... | |
T | Y |
Y coordinate of the vector. More... | |
T | Z |
Z coordinate of the vector. More... | |
3d vector template class with lots of operators and methods.
The vector3d class is used in Irrlicht for three main purposes: 1) As a direction vector (most of the methods assume this). 2) As a position in 3d space (which is synonymous with a direction vector from the origin to this position). 3) To hold three Euler rotations, where X is pitch, Y is yaw and Z is roll.
Definition at line 22 of file vector3d.h.
|
inline |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
Calculates the cross product with another vector.
p | Vector to multiply with. |
Definition at line 161 of file vector3d.h.
|
inline |
|
inline |
returns if this vector equals the other one, taking floating point rounding errors into account
Definition at line 120 of file vector3d.h.
|
inline |
Fills an array of 3 values with the vector data (usually floats).
Useful for setting in shader constants for example.
Definition at line 415 of file vector3d.h.
|
inline |
Fills an array of 4 values with the vector data (usually floats).
Useful for setting in shader constants for example. The fourth value will always be 0.
Definition at line 405 of file vector3d.h.
|
inline |
Get distance from another point.
Here, the vector is interpreted as point in 3 dimensional space.
Definition at line 146 of file vector3d.h.
|
inline |
Returns squared distance from another point.
Here, the vector is interpreted as point in 3 dimensional space.
Definition at line 153 of file vector3d.h.
|
inline |
Get the rotations that would make a (0,0,1) direction vector point in the same direction as this direction vector.
Thanks to Arras on the Irrlicht forums for this method. This utility method is very useful for orienting scene nodes towards specific targets. For example, if this vector represents the difference between two scene nodes, then applying the result of getHorizontalAngle() to one scene node will point it at the other one. Example code: Where target and seeker are of type ISceneNode* const vector3df toTarget(target->getAbsolutePosition() - seeker->getAbsolutePosition()); const vector3df requiredRotation = toTarget.getHorizontalAngle(); seeker->setRotation(requiredRotation);
Definition at line 315 of file vector3d.h.
|
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 261 of file vector3d.h.
|
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 273 of file vector3d.h.
|
inline |
|
inline |
Get squared length of the vector.
This is useful because it is much faster than getLength().
Definition at line 136 of file vector3d.h.
|
inline |
Get the spherical coordinate angles.
This returns Euler degrees for the point represented by this vector. The calculation assumes the pole at (0,1,0) and returns the angles in X and Y.
Definition at line 346 of file vector3d.h.
|
inline |
Definition at line 441 of file vector3d.h.
|
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 292 of file vector3d.h.
|
inline |
|
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 171 of file vector3d.h.
|
inline |
Normalizes the vector.
In case of the 0 vector the result is still 0, otherwise the length of the vector will be 1.
Definition at line 182 of file vector3d.h.
|
inline |
Definition at line 50 of file vector3d.h.
|
inline |
Definition at line 52 of file vector3d.h.
|
inline |
Definition at line 51 of file vector3d.h.
|
inline |
Definition at line 53 of file vector3d.h.
|
inline |
Definition at line 60 of file vector3d.h.
|
inline |
Definition at line 67 of file vector3d.h.
|
inline |
Definition at line 112 of file vector3d.h.
|
inline |
Definition at line 40 of file vector3d.h.
|
inline |
Definition at line 42 of file vector3d.h.
|
inline |
Definition at line 41 of file vector3d.h.
|
inline |
Definition at line 43 of file vector3d.h.
|
inline |
Definition at line 36 of file vector3d.h.
|
inline |
Definition at line 45 of file vector3d.h.
|
inline |
Definition at line 47 of file vector3d.h.
|
inline |
Definition at line 46 of file vector3d.h.
|
inline |
Definition at line 48 of file vector3d.h.
|
inline |
Definition at line 55 of file vector3d.h.
|
inline |
Definition at line 57 of file vector3d.h.
|
inline |
|
inline |
Definition at line 56 of file vector3d.h.
|
inline |
Definition at line 58 of file vector3d.h.
|
inline |
Definition at line 438 of file vector3d.h.
|
inline |
sort in order X, Y, Z. Difference must be above rounding tolerance.
Definition at line 91 of file vector3d.h.
|
inline |
sort in order X, Y, Z. Equality with rounding tolerance.
Definition at line 75 of file vector3d.h.
|
inline |
Definition at line 38 of file vector3d.h.
|
inline |
use weak float compare
Definition at line 107 of file vector3d.h.
|
inline |
sort in order X, Y, Z. Difference must be above rounding tolerance.
Definition at line 99 of file vector3d.h.
|
inline |
sort in order X, Y, Z. Equality with rounding tolerance.
Definition at line 83 of file vector3d.h.
|
inline |
Rotates the vector by a specified number of degrees around the Z axis and the specified center.
degrees | Number of degrees to rotate around the Z axis. |
center | The center of the rotation. |
Definition at line 229 of file vector3d.h.
|
inline |
Rotates the vector by a specified number of degrees around the Y axis and the specified center.
degrees | Number of degrees to rotate around the Y axis. |
center | The center of the rotation. |
Definition at line 214 of file vector3d.h.
|
inline |
Rotates the vector by a specified number of degrees around the X axis and the specified center.
degrees | Number of degrees to rotate around the X axis. |
center | The center of the rotation. |
Definition at line 244 of file vector3d.h.
|
inline |
Builds a direction vector from (this) rotation vector.
This vector is assumed to be a rotation vector composed of 3 Euler angle rotations, in degrees. The implementation performs the same calculations as using a matrix to do the rotation.
[in] | forwards | The direction representing "forwards" which will be rotated by this vector. If you do not provide a direction, then the +Z axis (0, 0, 1) will be assumed to be forwards. |
Definition at line 373 of file vector3d.h.
|
inline |
Definition at line 127 of file vector3d.h.
|
inline |
Definition at line 128 of file vector3d.h.
|
inline |
Sets the length of the vector to a new value.
Definition at line 196 of file vector3d.h.
T irr::core::vector3d< T >::X |
X coordinate of the vector.
Definition at line 424 of file vector3d.h.
T irr::core::vector3d< T >::Y |
Y coordinate of the vector.
Definition at line 427 of file vector3d.h.
T irr::core::vector3d< T >::Z |
Z coordinate of the vector.
Definition at line 430 of file vector3d.h.