vec4
Header file: include/vec4.h
vec4 is a vector with 4 scalars, x, y, z and w.
\(vec4 = \begin{bmatrix} x \\ y \\ z \\ w \end{bmatrix}\)
Class variables
Type |
Name |
Description |
|---|---|---|
float |
x |
The first element of the vec4. |
float |
y |
The second element of the vec4. |
float |
z |
The third element of the vec4. |
float |
w |
The fourth element of the vec4. |
Class functions
Constructors
Name |
Description |
|---|---|
Construct a (0.0, 0.0, 0.0, 0.0) vector. |
|
Construct a (_value, _value, _value, _value) vector. |
|
Construct a (_x, _y, _z, _w) vector. |
|
Construct a (_x, _yzw.x, _yzw.y, _yzw.z) vector. |
|
Construct a (_xyz.x, _xyz.y, _xyz.z, _w) vector. |
|
Construct a (_x, _y, _zw.x, _zw.y) vector. |
|
Construct a (_x, _yz.x, _yz.y, _w) vector. |
|
Construct a (_xy.x, _xy.y, _z, _w) vector. |
|
Construct a (_xy.x, _xy.y, _zw.x, _zw.y) vector. |
|
Construct a vector from a pointer. |
Operators
Name |
Description |
|---|---|
Add a vec4 to the current vec4. |
|
Substract a vec4 from the current vec4. |
|
Multiply the current vec4 by a scalar. |
|
Divide the current vec4 by a scalar. |
|
Return the negative of the current vec4. |
|
Return a reference to x if index is 0, a reference to y if index is 1, a reference to z if index is 2 or a reference to w if index is 3, else, throw an exception. |
|
Return the value of x if index is 0, the value of y if index is 1, the value of z if index is 2 or the value of w if index is 3, 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 vec4 that is the sum between two vec4. |
|
Return a vec4 that is the difference between two vec4. |
|
Return a vec4 that is the product between a vec4 and a scalar. |
|
Return a vec4 that is the product between a scalar and a vec4. |
|
Return a vec4 that is the quotient between a vec4 and a scalar. |
|
Return true if the two vec4 are identical, else, return false. |
|
Return true if the two vec4 are different, else, return false. |
Functions
Name |
Description |
|---|---|
Return a vec4 with the same direction as vec but with length 1. |
|
Return the dot product between two vec4. |
|
nml::vec4 nml::reflect(const nml::vec4& i, const nml::vec4& n) |
Return the reflected direction between the incident vector i and the normal n. n should be normalized. |
nml::vec4 nml::refract(const nml::vec4& i, const nml::vec4& 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 vec4 as a string under the format “[x, y, z, w]”. |