HighMap library (C++)
|
Vec4 class for basic manipulation of 4D vectors. More...
#include <algebra.hpp>
Public Member Functions | |
Vec4 () | |
Default constructor initializing the vector to (0, 0, 0, 0). | |
Vec4 (T a, T b, T c, T d) | |
Parameterized constructor initializing the vector to given values. | |
Vec4 (const std::vector< T > &vec) | |
Constructs a Vec4 object from a std::vector. | |
bool | operator== (const Vec4 &other_vec) const |
Equality operator. | |
bool | operator!= (const Vec4 &other_vec) const |
Inequality operator. | |
Vec4 & | operator/= (const T value) |
Division-assignment operator. | |
Vec4 | operator/ (const Vec4 &other_vec) const |
Division operator. | |
Vec4 | operator* (const Vec4 &other_vec) const |
Multiplication operator. | |
Vec4 | operator+ (const Vec4 &other_vec) const |
Addition operator. | |
Vec4 | operator- (const Vec4 &other_vec) const |
Subtraction operator. | |
Vec4 | operator* (T scalar) const |
Scalar multiplication (Vec4 * scalar). | |
Vec4< T > | adjust (float da, float db, float dc, float dd) |
Adjusts the components of the vector by the given offsets. | |
Public Attributes | |
T | a |
T | b |
T | c |
T | d |
The a, b, c, and d components of the vector. | |
Friends | |
Vec4 | operator* (T scalar, const Vec4 &vec) |
Scalar multiplication (scalar * Vec4). | |
float | dot (const Vec4 v1, const Vec4 v2) |
Friend function to calculate the dot product of two vectors. | |
Vec4 class for basic manipulation of 4D vectors.
This class provides basic operations for 4D vectors, such as addition, subtraction, multiplication, division, and dot product calculation. The class supports various data types through templating.
T | Data type for the vector components (e.g., int, float, double). |
|
inline |
Default constructor initializing the vector to (0, 0, 0, 0).
Initializes the a, b, c, and d components to zero.
|
inline |
Parameterized constructor initializing the vector to given values.
a | The a component of the vector. |
b | The b component of the vector. |
c | The c component of the vector. |
d | The d component of the vector. |
|
inline |
Constructs a Vec4 object from a std::vector.
This constructor takes a vector containing exactly four elements and assigns the first element to a
, the second to b
, the third to c
, and the fourth to d
.
T | The type of elements in the vector (e.g., float, int, double). |
vec | A const reference to a vector of size 4, where the first element corresponds to a , the second to b , the third to c , and the fourth to d . |
std::invalid_argument | If the vector does not contain exactly four elements. |
|
inline |
Equality operator.
Compares two vectors for equality.
other_vec | The vector to compare with. |
|
inline |
Inequality operator.
Compares two vectors for inequality.
other_vec | The vector to compare with. |
|
inline |
Division-assignment operator.
Divides all components of the vector by a scalar value and assigns the result.
value | The scalar value to divide by. |
|
inline |
Division operator.
Divides each component of the vector by the corresponding component of another vector.
other_vec | The vector to divide by. |
|
inline |
Multiplication operator.
Multiplies each component of the vector by the corresponding component of another vector.
other_vec | The vector to multiply by. |
|
inline |
Addition operator.
Adds each component of the vector to the corresponding component of another vector.
other_vec | The vector to add. |
|
inline |
Subtraction operator.
Subtracts each component of another vector from the corresponding component of this vector.
other_vec | The vector to subtract. |
|
inline |
|
inline |
Adjusts the components of the vector by the given offsets.
This method creates a new vector by adding the specified offsets to the respective components of the current vector.
T | The type of the vector components. |
da | The offset to add to the first component (a ). |
db | The offset to add to the second component (b ). |
dc | The offset to add to the third component (c ). |
dd | The offset to add to the fourth component (d ). |
Scalar multiplication (scalar * Vec4).
Multiplies each component of the vector by a scalar value. This function allows expressions where the scalar is on the left side of the multiplication operator.
scalar | The scalar value to multiply with. |
vec | The vector to multiply. |
Friend function to calculate the dot product of two vectors.
The dot product is the sum of the products of the corresponding components of the vectors.
v1 | The first vector. |
v2 | The second vector. |
T hmap::Vec4< T >::a |
T hmap::Vec4< T >::b |
T hmap::Vec4< T >::c |
T hmap::Vec4< T >::d |
The a, b, c, and d components of the vector.