|
t
|
The 3D vector class. More...
#include <Vector3.hpp>
Public Member Functions | |
| Vector3 (double _x, double _y, double _z) | |
| Creates a new 3D vector with the specified components. | |
| Vector3 | clone () const |
| Returns a copy of this 3D vector. | |
| Vector3 & | copy (const Vector3 &source) |
| Copies the components of the specified 3D vector to this 3D vector. | |
| Vector3 & | set (double _x, double _y, double _z) |
| Sets the components of this vector. | |
| double | length () const |
| Returns the length of this 3D vector. | |
| Vector3 | unit () const |
| Returns the unit vector of this 3D vector. | |
| Vector3 & | normalize () |
| Normalizes this 3D vector. | |
| Vector3 | absolute () const |
| Returns a new 3D vector with the absolute values of the components of this 3D vector. | |
| Vector3 & | abs () |
| Sets the components of this 3D vector to their absolute values. | |
| Vector3 & | clamp (const Vector3 &min, const Vector3 &max) |
| Clamps the components of this 3D vector to the specified minimum and maximum 3D vectors component-wise. | |
| Vector3 & | clamp (double min, double max) |
| Clamps the components of this 3D vector to the specified minimum and maximum values. | |
| double | operator[] (std::size_t index) const |
| Returns the component at the specified index of this 3D vector. | |
| Vector3 & | operator+= (const Vector3 &v) |
| Adds the specified 3D vector to this vector. | |
| Vector3 & | operator+= (double s) |
| Adds the specified constant to all components in this 3D vector. | |
| Vector3 & | operator-= (const Vector3 &v) |
| Subtracts the specified 3D vector from this vector. | |
| Vector3 & | operator-= (double s) |
| Subtracts the specified constant from all components in this 3D vector. | |
| Vector3 & | operator*= (const Vector3 &v) |
| Multiplies the components of this vector with the corresponding components of the specified 3D vector. | |
| Vector3 & | operator*= (double s) |
| Multiplies all components of this 3D vector with the specified constant. | |
| Vector3 & | operator/= (const Vector3 &v) |
| Divides the components of this vector by the corresponding components of another 3D vector. | |
| Vector3 & | operator/= (double s) |
| Divides the components of this 3D vector by the specified constant. | |
Static Public Member Functions | |
| static Vector3 | fromBufferAttribute (const BufferAttribute< double > &bufferAttribute, int index) |
Returns 3 consecutive values at the specified index in a BufferAttribute at the specified in a Vector3. | |
| static Vector3 | cross (const Vector3 &a, const Vector3 &b) |
| Returns the cross product of two vectors. | |
| static double | dot (const Vector3 &a, const Vector3 &b) |
| Returns the dot product of two vectors. | |
| static Vector3 | reflect (const Vector3 &incident, const Vector3 &surfaceOrientation) |
| Returns the reflection of an incident vector off a surface that has the specified orientation. | |
Public Attributes | |
| double | x |
| The x component of this 3D vector. | |
| double | y |
| The y component of this 3D vector. | |
| double | z |
| The z component of this 3D vector. | |
Friends | |
| bool | operator== (const Vector3 &a, const Vector3 &b)=default |
| Returns whether if two 3D vectors are equal. | |
| Vector3 | operator- (const Vector3 &a) |
| Returns the negation of this 3D vector. | |
| Vector3 | operator+ (const Vector3 &a, const Vector3 &b) |
| Adds two 3D vectors. | |
| Vector3 | operator+ (const Vector3 &a, double s) |
| Adds a constant to all components of a 3D vector. | |
| Vector3 | operator+ (double s, const Vector3 &a) |
| Adds a constant to all components of a 3D vector. | |
| Vector3 | operator- (const Vector3 &a, const Vector3 &b) |
| Subtracts two 3D vectors. | |
| Vector3 | operator- (const Vector3 &a, double s) |
| Subtracts a constant from all components of a 3D vector. | |
| Vector3 | operator- (double s, const Vector3 &a) |
| Subtracts a 3D vector from a constant 3D vector. | |
| Vector3 | operator* (const Vector3 &a, const Vector3 &b) |
| Returns the element-wise product of two 3D vectors, also known as the Hadamard product. | |
| Vector3 | operator* (const Vector3 &a, double s) |
| Multiplies all components of a 3D vector with a constant. | |
| Vector3 | operator* (double s, const Vector3 &a) |
| Multiplies all components of a 3D vector with a constant. | |
| Vector3 | operator/ (const Vector3 &a, const Vector3 &b) |
| Returns the element-wise division of two 3D vectors. | |
| Vector3 | operator/ (const Vector3 &a, double s) |
| Divides the components of a 3D vector by a constant. | |
| Vector3 | operator/ (double s, const Vector3 &a) |
| Returns the element-wise division of a constant 3D vector and a 3D vector. | |
The 3D vector class.
A 3D vector is a triplet of numbers labeled x, y, and z which can be used to represent a number of things e.g. 3D coordinates, Euler angles, RGB colors, etc.
|
inline |
Creates a new 3D vector with the specified components.
| _x | The x component of the new 3D vector. |
| _y | The y component of the new 3D vector. |
| _z | The z component of the new 3D vector. |
|
inline |
Sets the components of this 3D vector to their absolute values.
Note that this method modifies this instance. If you want to avoid modification, use absolute instead.
|
inline |
Returns a new 3D vector with the absolute values of the components of this 3D vector.
Clamps the components of this 3D vector to the specified minimum and maximum 3D vectors component-wise.
| min | The minimum 3D vector. |
| max | The maximum 3D vector. |
|
inline |
Clamps the components of this 3D vector to the specified minimum and maximum values.
| min | The minimum value. |
| max | The maximum value. |
|
inline |
Returns a copy of this 3D vector.
Copies the components of the specified 3D vector to this 3D vector.
| source | A 3D vector to copy the components from. |
Returns the cross product of two vectors.
| a | The first vector. |
| b | The second vector. |
Returns the dot product of two vectors.
| a | The first vector. |
| b | The second vector. |
|
inlinestatic |
Returns 3 consecutive values at the specified index in a BufferAttribute at the specified in a Vector3.
| bufferAttribute | The attribute to get the values from. |
| index | The index of the first value in the index. |
Vector3 with 3 consecutive values starting at the specified index.
|
inline |
Returns the length of this 3D vector.
Specifically, returns the Euclidean length.
|
inline |
Normalizes this 3D vector.
Note that this method modifies this instance. If you want to avoid modification, use unit instead.
|
inline |
Multiplies all components of this 3D vector with the specified constant.
| s | A constant. |
Adds the specified 3D vector to this vector.
| v | A 3D vector. |
|
inline |
Adds the specified constant to all components in this 3D vector.
| s | A constant. |
Subtracts the specified 3D vector from this vector.
| v | A 3D vector. |
|
inline |
Subtracts the specified constant from all components in this 3D vector.
| s | A constant. |
Divides the components of this vector by the corresponding components of another 3D vector.
| v | A 3D vector. |
|
inline |
Divides the components of this 3D vector by the specified constant.
| s | A constant. |
|
inline |
Returns the component at the specified index of this 3D vector.
| index | A 0-based index. Must be 0, 1, or 2. |
index. | std::invalid_argument | if index is not 0, 1, or 2. |
|
inlinestatic |
Returns the reflection of an incident vector off a surface that has the specified orientation.
The reflection is calculated as \(\vec{v} - 2 \cdot (\vec{s} \cdot \vec{v}) \cdot \vec{s}\) where \(\vec{v}\) is the incident vector and \(\vec{s}\) is the surface orientation.
| incident | The incident vector. |
| surfaceOrientation | The surface orientation. |
|
inline |
Sets the components of this vector.
| _x | The new x component. |
| _y | The new y component. |
| _z | The new z component. |
|
inline |
Returns the unit vector of this 3D vector.
Returns the element-wise product of two 3D vectors, also known as the Hadamard product.
| a | A 3D vector. |
| b | Another 3D vector. |
a and b. Multiplies all components of a 3D vector with a constant.
| a | A 3D vector. |
| s | A constant. |
a with s. Multiplies all components of a 3D vector with a constant.
| s | A constant. |
| a | A 3D vector. |
a with s. Adds two 3D vectors.
| a | A 3D vector. |
| b | Another 3D vector. |
a and b. Adds a constant to all components of a 3D vector.
| a | A 3D vector. |
| s | A constant. |
s to the components of a. Adds a constant to all components of a 3D vector.
| s | A constant. |
| a | A 3D vector. |
s to the components of a. Returns the negation of this 3D vector.
Subtracts two 3D vectors.
| a | A 3D vector. |
| b | Another 3D vector. |
a and b. Subtracts a constant from all components of a 3D vector.
| a | A 3D vector. |
| s | A constant. |
s from the components of a. Subtracts a 3D vector from a constant 3D vector.
A constant vector is a vector whose components are all the same.
| s | A constant for the constant 3D vector. |
| a | A 3D vector. |
a from the constant vector of s. Returns the element-wise division of two 3D vectors.
| a | A 3D vector. |
| b | Another 3D vector. |
a and b. Divides the components of a 3D vector by a constant.
| a | A 3D vector. |
| s | A constant. |
a by s. Returns the element-wise division of a constant 3D vector and a 3D vector.
A constant vector is a vector whose components are all the same.
| s | A constant for the constant 3D vector. |
| a | A 3D vector. |
a. Returns whether if two 3D vectors are equal.
true if the two vectors are equal, false otherwise.