The Vector3 class represents a vector or vertex in 3D space. More...
#include <vector3.h>
Public Member Functions | |
| Vector3 ()=default | |
| Constructs a null vector, i.e. | |
| Vector3 (double x, double y, double z) | |
| Constructs a vector with coordinates (x, y, z). | |
| Vector3 (const Vector3 &v)=default | |
| Constructs a vector object as a copy of v. | |
| double | Length () const |
| Returns the length of the vector from the origin. | |
| void | Normalize () |
| Normalizes the currect vector in place. | |
| double | X () const |
| Returns the x coordinate of this vector. | |
| double | Y () const |
| Returns the y coordinate of this vector. | |
| double | Z () const |
| Returns the z coordinate of this vector. | |
| void | SetX (double x) |
| Sets the x coordinate of this vector to the given x coordinate. | |
| void | SetY (double y) |
| Sets the y coordinate of this vector to the given y coordinate. | |
| void | SetZ (double z) |
| Sets the z coordinate of this vector to the given z coordinate. | |
| const double & | operator[] (size_t i) const |
| Returns the component of the vector at index position i. | |
| double & | operator[] (size_t i) |
| Returns the component of the vector at index position i as a modifiable reference. | |
| Vector3 & | operator= (const Vector3 &v)=default |
| Sets this Vector3 object as a copy of v. | |
Static Public Member Functions | |
| static double | DotProduct (const Vector3 &v1, const Vector3 &v2) |
| Returns the dot product of v1 and v2. | |
| static Vector3 | CrossProduct (const Vector3 &v1, const Vector3 &v2) |
| Returns the cross-product of vectors v1 and v2, which corresponds to the normal vector of a plane defined by v1 and v2. | |
The Vector3 class represents a vector or vertex in 3D space.
Vectors are one of the main building blocks of 3D representation and drawing. They consist of three coordinates, traditionally called x, y, and z.
|
default |
Constructs a null vector, i.e.
with coordinates (0, 0, 0).
| Vector3 | ( | double | x, |
| double | y, | ||
| double | z ) |
Constructs a vector with coordinates (x, y, z).
Definition at line 38 of file vector3.cpp.
Returns the cross-product of vectors v1 and v2, which corresponds to the normal vector of a plane defined by v1 and v2.
Definition at line 66 of file vector3.cpp.
Returns the dot product of v1 and v2.
Definition at line 61 of file vector3.cpp.
| double Length | ( | ) | const |
Returns the length of the vector from the origin.
Definition at line 45 of file vector3.cpp.
| void Normalize | ( | ) |
Normalizes the currect vector in place.
Nothing happens if this vector is a null vector or the length of the vector is very close to 1.
Definition at line 50 of file vector3.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |