vec3
Header file: include/vec3.h
vec3 is a vector with 3 scalars, x, y and z.
\(vec3 = \begin{bmatrix} x \\ y \\ z \end{bmatrix}\)
Class variables
Type |
Name |
Description |
|---|---|---|
float |
x |
The first element of the vec3. |
float |
y |
The second element of the vec3. |
float |
z |
The third element of the vec3. |
Class functions
Constructors
Name |
Description |
|---|---|
Construct a (0.0, 0.0, 0.0) vector. |
|
Construct a (_value, _value, _value) vector. |
|
Construct a (_x, _y, _z) vector. |
|
Construct a (_x, _yz.x, _yz.y) vector. |
|
Construct a (_xy.x, _xy.y, _z) vector. |
|
Construct a vector from a pointer. |
|
Construct a (_xyzw.x, _xyzw.y, _xyzw.z) vector. |
Operators
Name |
Description |
|---|---|
Add a vec3 to the current vec3. |
|
Substract a vec3 from the current vec3. |
|
Multiply the current vec3 by a scalar. |
|
Divide the current vec3 by a scalar. |
|
Return the negative of the current vec3. |
|
Return a reference to x if index is 0, a reference to y if index is 1 or a reference to z if index is 2, else, throw an exception. |
|
Return the value of x if index is 0, the value of y if index is 1 or the value to z if index is 2, else, throw an exception. |
Functions
Name |
Description |
|---|---|
Return the length of the vector. |
|
Return a pointer to the vector’s elements. |
Namespace functions
Operators
Name |
Description |
|---|---|
Return a vec3 that is the sum between two vec3. |
|
Return a vec3 that is the difference between two vec3. |
|
Return a vec3 that is the product between a vec3 and a scalar. |
|
Return a vec3 that is the product between a scalar and a vec3. |
|
Return a vec3 that is the quotient between a vec3 and a scalar. |
|
Return true if the two vec3 are identical, else, return false. |
|
Return true if the two vec3 are different, else, return false. |
Functions
Name |
Description |
|---|---|
Return a vec3 with the same direction as vec but with length 1. |
|
Return the dot product between two vec3. |
|
nml::vec3 nml::cross(const nml::vec3& a, const nml::vec3& b) |
Return the cross product between two vec3. |
nml::vec3 nml::reflect(const nml::vec3& i, const nml::vec3& n) |
Return the reflected direction between the incident vector i and the normal n. n should be normalized. |
nml::vec3 nml::refract(const nml::vec3& i, const nml::vec3& n, float ior) |
Return the refracted direction between the incident vector i, the normal n and the ratio of indices of refraction ior. n should be normalized. |
Return a vec3 representing euler angles in radians from a quaternion. |
|
nml::vec3 nml::rotationMatrixToEulerAngles(const nml::mat4& mat) |
Return a vec3 representing euler angles in radians from a 3D rotation matrix. |
Return a vec3 as a string under the format “[x, y, z]”. |