A triplet of coordinates in 3D. More...
Public Member Functions | |
Vector3D (float x=0.0f, float y=0.0f, float z=0.0f) | |
Constructor for the Vector3D. | |
Vector3D & | operator+= (const Vector3D &v) |
Adds a Vector3D. | |
Vector3D & | operator-= (const Vector3D &v) |
Substracts a Vector3D. | |
Vector3D & | operator+= (float f) |
Adds a floating number. | |
Vector3D & | operator-= (float f) |
Substracts a floating number. | |
Vector3D & | operator*= (float f) |
Multiplies by a floating number. | |
Vector3D & | operator/= (float f) |
Divides by a floating number. | |
Vector3D | operator- () const |
Unary - operator of Vector3D. | |
float & | operator[] (size_t index) |
Accesses the Vector3D coordinates in an container like fashion. | |
const float & | operator[] (size_t index) const |
Accesses the Vector3D coordinates in an container like fashion. | |
void | set (float x, float y, float z=0.0f) |
Sets the values of the Vector3D. | |
float | getSqrNorm () const |
Gets the square norm of the Vector3D. | |
float | getNorm () const |
Gets the norm of the Vector3D. | |
bool | normalize () |
Normalizes the Vector3D. | |
void | revert () |
Reverts the Vector3D. | |
void | abs () |
Sets this Vector3D to its absolute values. | |
void | crossProduct (const Vector3D &v) |
Computes the cross product between v and the vector3D and store the result in the vector3D. | |
Public Attributes | |
float | x |
x coordinate of the vector | |
float | y |
y coordinate of the vector | |
float | z |
z coordinate of the vector |
A triplet of coordinates in 3D.
This class offers a set of methods to manipulate 3D points/vectors.
To make the use of 3D points/vectors easier and more intuitive, some operators are overloaded.
Vector3D are the basic primitive used in SPARK to define 3D points/vectors.
Note that Vector3D coordinates are accessible directly without any setters or getters.
Definition at line 41 of file SPK_Vector3D.h.
Vector3D | ( | float | x = 0.0f , |
|
float | y = 0.0f , |
|||
float | z = 0.0f | |||
) |
Constructor for the Vector3D.
x | : x coordinate | |
y | : y coordinate | |
z | : z coordinate |
void abs | ( | ) |
Sets this Vector3D to its absolute values.
This method performs these operations :
x = abs(x)
y = abs(y)
z = abs(z)
void crossProduct | ( | const Vector3D & | v | ) |
Computes the cross product between v and the vector3D and store the result in the vector3D.
v | : the vector3D used to compute the cross product (*this x v) |
float getNorm | ( | ) | const |
Gets the norm of the Vector3D.
the norm is defined as sqrt(x * x + y * y + z * z).
Definition at line 488 of file SPK_Vector3D.h.
float getSqrNorm | ( | ) | const |
Gets the square norm of the Vector3D.
the square norm is defined as x * x + y * y + z * z. This method is faster than getNorm() and should be used when possible.
Definition at line 483 of file SPK_Vector3D.h.
bool normalize | ( | ) |
Vector3D& operator*= | ( | float | f | ) |
Vector3D& operator+= | ( | float | f | ) |
Adds a floating number.
This method performs these operations :
x += f
y += f
z += f
f | : the number to add |
Vector3D operator- | ( | ) | const |
Vector3D& operator-= | ( | float | f | ) |
Substracts a floating number.
This method performs these operations :
x -= f
y -= f
z -= f
f | : the number to substract |
Vector3D& operator/= | ( | float | f | ) |
const float& operator[] | ( | size_t | index | ) | const |
Accesses the Vector3D coordinates in an container like fashion.
This is the constant version of operator[](size_t)
index | : the index of the coordinate to get (from 0 to 2) |
float& operator[] | ( | size_t | index | ) |
Accesses the Vector3D coordinates in an container like fashion.
Note that no check for out of bounds index is performed
index | : the index of the coordinate to get (from 0 to 2) |
void revert | ( | ) |
Reverts the Vector3D.
This method performs these operations :
x = -x
y = -y
z = -z
void set | ( | float | x, | |
float | y, | |||
float | z = 0.0f | |||
) |
Sets the values of the Vector3D.
x | : x coordinate | |
y | : y coordinate | |
z | : z coordinate |
float x |
x coordinate of the vector
Definition at line 49 of file SPK_Vector3D.h.
float y |
y coordinate of the vector
Definition at line 50 of file SPK_Vector3D.h.
float z |
z coordinate of the vector
Definition at line 51 of file SPK_Vector3D.h.