Isle
|
[AI] A four-dimensional vector, supporting operations relevant for matrix and quaternion math (homogeneous coordinates). More...
#include <vector.h>
Public Member Functions | |
Vector4 (float *p_data) | |
[AI] Constructs a Vector4 using external float storage. More... | |
Vector4 (const float *p_data) | |
[AI] Constructs a Vector4 using a const float pointer (pointer is reinterpreted as mutable). More... | |
void | Clear () override |
[AI] Sets all four components to zero. More... | |
float | LenSquared () const override |
[AI] Computes the squared magnitude of the 4D vector. More... | |
void | Fill (const float &p_value) override |
[AI] Fill all four floats with p_value. More... | |
virtual void | SetMatrixProduct (const float *p_vec, const float *p_mat) |
[AI] Set this vector to the result of a matrix-vector product: result = p_mat * p_vec. More... | |
virtual void | SetMatrixProduct (const Vector4 &p_a, const float *p_b) |
[AI] Set this vector to result of matrix-vector product with source given as Vector4, matrix as pointer. More... | |
virtual int | NormalizeQuaternion () |
[AI] Normalize this quaternion (interpreted as vector) in place. More... | |
virtual int | EqualsHamiltonProduct (const Vector4 &p_a, const Vector4 &p_b) |
[AI] Set this vector to the Hamilton product of two quaternion Vector4s. More... | |
float & | operator[] (int idx) |
[AI] Indexes 0-3: returns reference to the fast access coordinate. More... | |
const float & | operator[] (int idx) const |
[AI] Const version for coordinate access (0...3). More... | |
![]() | |
Vector3 (float *p_data) | |
[AI] Construct a 3D vector pointing at external data storage. More... | |
Vector3 (const float *p_data) | |
[AI] Construct a 3D vector from const float* (pointer is cast to non-const in base). More... | |
void | Clear () override |
[AI] Sets every coordinate (x, y, z) to zero. More... | |
float | LenSquared () const override |
[AI] Computes the squared magnitude (x^2 + y^2 + z^2) of this vector. More... | |
virtual void | EqualsCross (const Vector3 &p_a, const Vector3 &p_b) |
[AI] Sets this vector to be the cross product of p_a and p_b. More... | |
virtual void | EqualsCross (const Vector3 &p_a, const float *p_b) |
[AI] Sets this vector to be the cross product of p_a and p_b, with b as a pointer. More... | |
virtual void | EqualsCross (const float *p_a, const Vector3 &p_b) |
[AI] Sets this vector to be the cross product of p_a and p_b, with a as a pointer. More... | |
virtual void | Fill (const float &p_value) |
[AI] Fills all coordinates with p_value. More... | |
![]() | |
Vector2 (float *p_data) | |
[AI] Construct a 2D vector using an external float buffer. More... | |
Vector2 (const float *p_data) | |
[AI] Construct a 2D vector from a (likely constant) array of floats without copying (just pointer assignment). More... | |
virtual float * | GetData () |
[AI] Retrieves the mutable in-memory data pointer for this vector. More... | |
virtual const float * | GetData () const |
[AI] Retrieves the immutable data pointer for this vector. More... | |
virtual void | Clear () |
[AI] Zeros all elements (sets all coordinates to 0.0). More... | |
virtual float | Dot (const float *p_a, const float *p_b) const |
[AI] Compute the dot product of the two float arrays interpreted as vectors of 2 elements. More... | |
virtual float | Dot (const Vector2 &p_a, const Vector2 &p_b) const |
[AI] Compute the dot product of two Vector2 objects. More... | |
virtual float | Dot (const float *p_a, const Vector2 &p_b) const |
[AI] Compute the dot product given a pointer and a Vector2 (second param). More... | |
virtual float | Dot (const Vector2 &p_a, const float *p_b) const |
[AI] Compute the dot product given a Vector2 (first param) and a pointer (second param). More... | |
virtual float | LenSquared () const |
[AI] Compute the squared length (magnitude^2) of the vector. More... | |
virtual int | Unitize () |
[AI] Scales the vector so its norm is 1 (unit vector). More... | |
virtual void | operator+= (float p_value) |
[AI] In-place add a scalar to all coordinates. More... | |
virtual void | operator+= (const float *p_other) |
[AI] In-place add vector elements via float pointer. More... | |
virtual void | operator+= (const Vector2 &p_other) |
[AI] In-place add another Vector2. More... | |
virtual void | operator-= (const float *p_other) |
[AI] In-place subtraction of vector pointed to by p_other. More... | |
virtual void | operator-= (const Vector2 &p_other) |
[AI] In-place subtraction of another Vector2. More... | |
virtual void | operator*= (const float *p_other) |
[AI] In-place per-element multiplication of this vector by another array. More... | |
virtual void | operator*= (const Vector2 &p_other) |
[AI] In-place per-element multiplication by another Vector2. More... | |
virtual void | operator*= (const float &p_value) |
[AI] In-place multiplication by a scalar. More... | |
virtual void | operator/= (const float &p_value) |
[AI] In-place scalar division. More... | |
virtual void | operator= (const float *p_other) |
[AI] Assigns this vector's elements from a pointer to two floats. More... | |
virtual void | operator= (const Vector2 &p_other) |
[AI] Assigns this vector's elements from another Vector2. More... | |
float & | operator[] (int idx) |
[AI] Accesses the idx-th float in the vector (0 or 1). More... | |
const float & | operator[] (int idx) const |
[AI] Const version of the index operator. More... | |
Protected Member Functions | |
void | AddImpl (const float *p_value) override |
[AI] Adds the values pointed to by p_value to this vector. More... | |
void | AddImpl (float p_value) override |
[AI] Adds a scalar value to every element of this vector. More... | |
void | SubImpl (const float *p_value) override |
[AI] Subtracts the vector specified by p_value from this vector. More... | |
void | MulImpl (const float *p_value) override |
[AI] Multiplies this vector by another vector (per element). More... | |
void | MulImpl (const float &p_value) override |
[AI] Multiplies this vector by a scalar value. More... | |
void | DivImpl (const float &p_value) override |
[AI] Divides this vector by a scalar value. More... | |
float | DotImpl (const float *p_a, const float *p_b) const override |
void | EqualsImpl (const float *p_data) override |
[AI] Assigns values from provided array to this vector. More... | |
![]() | |
void | AddImpl (const float *p_value) override |
[AI] Adds the values pointed to by p_value to this vector. More... | |
void | AddImpl (float p_value) override |
[AI] Adds a scalar value to every element of this vector. More... | |
void | SubImpl (const float *p_value) override |
[AI] Subtracts the vector specified by p_value from this vector. More... | |
void | MulImpl (const float *p_value) override |
[AI] Multiplies this vector by another vector (per element). More... | |
void | MulImpl (const float &p_value) override |
[AI] Multiplies this vector by a scalar value. More... | |
void | DivImpl (const float &p_value) override |
[AI] Divides this vector by a scalar value. More... | |
float | DotImpl (const float *p_a, const float *p_b) const override |
void | EqualsImpl (const float *p_data) override |
[AI] Assigns values from provided array to this vector. More... | |
virtual void | EqualsCrossImpl (const float *p_a, const float *p_b) |
[AI] Assigns this vector to the cross product of p_a and p_b. More... | |
![]() | |
virtual void | AddImpl (const float *p_value) |
[AI] Adds the values pointed to by p_value to this vector. More... | |
virtual void | AddImpl (float p_value) |
[AI] Adds a scalar value to every element of this vector. More... | |
virtual void | SubImpl (const float *p_value) |
[AI] Subtracts the vector specified by p_value from this vector. More... | |
virtual void | MulImpl (const float *p_value) |
[AI] Multiplies this vector by another vector (per element). More... | |
virtual void | MulImpl (const float &p_value) |
[AI] Multiplies this vector by a scalar value. More... | |
virtual void | DivImpl (const float &p_value) |
[AI] Divides this vector by a scalar value. More... | |
virtual float | DotImpl (const float *p_a, const float *p_b) const |
[AI] Computes the dot product of two arrays interpreted as vectors. More... | |
virtual void | SetData (float *p_data) |
[AI] Set the internal data pointer to external storage. More... | |
virtual void | EqualsImpl (const float *p_data) |
[AI] Assigns values from provided array to this vector. More... | |
Friends | |
class | Mx4DPointFloat |
Additional Inherited Members | |
![]() | |
float * | m_data |
[AI] Pointer to externally provided float storage (owned elsewhere). More... | |
[AI] A four-dimensional vector, supporting operations relevant for matrix and quaternion math (homogeneous coordinates).
Inherits from Vector3.
[AI] Adds 4D-specific functions: matrix product, quaternion normalization, and quaternion Hamilton products. Facilitates 3D transformations and animation math.
|
inline |
|
inline |
|
inlineoverrideprotectedvirtual |
[AI] Adds the values pointed to by p_value to this vector.
[AI] Implements vector addition for Vector4 using a float array as input.
[AI] Adds a 2D float array to the vector data in-place.
p_value | Pointer to an array containing values to add. [AI] |
This is used for vector addition with an array.
p_value | Pointer to a float array containing the values to add. |
[AI] Each component of the input array is added to the corresponding component of the vector. The length must be 2.
This method adds the elements of p_value (assumed to be an array of at least four floats) to this vector's components, modifying all four entries including the w component. Calls Vector3::AddImpl for the first three elements and adds the fourth explicitly.
p_value | Pointer to an array of four floats to add to the vector components. [AI] |
Reimplemented from Vector3.
|
inlineoverrideprotectedvirtual |
[AI] Adds a scalar value to every element of this vector.
[AI] Adds a scalar value to all four components of the vector.
[AI] Adds a scalar value to both components of the vector.
p_value | The value to add to each coordinate. [AI] |
p_value | The scalar value to add. |
[AI] The scalar is added to both x and y components.
Each component (x, y, z, w) has p_value added to it.
p_value | Scalar value to add to each component. [AI] |
Reimplemented from Vector3.
|
inlineoverridevirtual |
[AI] Sets all four components to zero.
[AI] Sets all four components of the vector to zero.
Uses memset to set all data entries to 0.
Reimplemented from Vector3.
|
inlineoverrideprotectedvirtual |
[AI] Divides this vector by a scalar value.
[AI] Divides all components of the vector by a scalar value.
[AI] Divides both components of the vector by a scalar.
p_value | Scalar divisor. [AI] |
p_value | The scalar value to divide by. |
[AI] Both components are divided by the scalar. No zero check.
Each component (x, y, z, w) is divided by p_value.
p_value | Scalar divisor. [AI] |
Reimplemented from Vector3.
|
inlineoverrideprotectedvirtual |
[AI] Calculates the dot product for two float[4] arrays as if they are 4D vectors.
The dot product includes all four components.
p_a | First operand, array of 4 floats. [AI] |
p_b | Second operand, array of 4 floats. [AI] |
Reimplemented from Vector3.
[AI] Set this vector to the Hamilton product of two quaternion Vector4s.
[AI] Sets this vector to the Hamilton product of two quaternions (Vector4s).
The result is the quaternion multiplication of p_a and p_b, written into this. Uses Vector3 cross product for the vector part and a combination of scalar and vector terms for the real part.
p_a | Left operand quaternion. [AI] |
p_b | Right operand quaternion. [AI] |
|
inlineoverrideprotectedvirtual |
[AI] Assigns values from provided array to this vector.
[AI] Sets the vector's components to those in a float[4] array.
[AI] Copies the values from a float array into the vector's data.
p_data | Pointer to array to copy from. [AI] |
p_data | Pointer to float array containing the values to copy. |
[AI] Uses memcpy for fast assignment of both vector components.
Performs a memcpy for all four components.
p_data | Pointer to an array of four floats to copy from. [AI] |
Reimplemented from Vector3.
|
inlineoverridevirtual |
[AI] Fill all four floats with p_value.
[AI] Sets all components of the vector to the given value.
p_value | The value to assign everywhere. [AI] |
Fills x, y, z, w with p_value.
p_value | The value to assign to all components. [AI] |
Reimplemented from Vector3.
|
inlineoverridevirtual |
|
inlineoverrideprotectedvirtual |
[AI] Multiplies this vector by a scalar value.
[AI] Multiplies all components of the vector by a scalar.
[AI] Multiplies both components of the vector by a scalar.
p_value | Scalar multiplier. [AI] |
p_value | The scalar value to multiply by. |
[AI] Both components are multiplied by the scalar.
Each component (x, y, z, w) is multiplied by p_value.
p_value | Scalar multiplier. [AI] |
Reimplemented from Vector3.
|
inlineoverrideprotectedvirtual |
[AI] Multiplies this vector by another vector (per element).
[AI] Multiplies each component of the vector by the corresponding element of p_value.
[AI] Multiplies the vector by another 2D float array component-wise.
p_value | Pointer to the vector to multiply with. [AI] |
p_value | Pointer to a float array containing the values to multiply by. |
[AI] Each component of the vector is multiplied by the corresponding component in the input array.
Multiplies x, y, z using Vector3::MulImpl and multiplies w by p_value[3].
p_value | Pointer to an array of four floats for component-wise multiplication. [AI] |
Reimplemented from Vector3.
|
inlinevirtual |
[AI] Normalize this quaternion (interpreted as vector) in place.
[AI] Normalizes the vector as a quaternion.
Result is 0 if success.
If x, y, z components' squared length is nonzero, the quaternion is normalized:
(x, y, z) is scaled based on sin(theta)/sqrt(length) If not, returns -1 as error.
[AI] This is useful for ensuring a quaternion used for rotations is normalized.
|
inline |
|
inline |
|
inlinevirtual |
[AI] Set this vector to the result of a matrix-vector product: result = p_mat * p_vec.
[AI] Sets the vector as a matrix product of a 4D vector with a 4x4 matrix (column-major).
p_vec | Pointer to the input vector (length 4). [AI] |
p_mat | Pointer to 4x4 matrix (row-major). [AI] |
The product is: m_data[i] = sum_over_j(p_vec[j] * p_mat[j*4 + i])
p_vec | The 4D input vector as an array. [AI] |
p_mat | The 4x4 matrix as a flat array of 16 floats (column-major order). [AI] |
|
inlinevirtual |
[AI] Set this vector to result of matrix-vector product with source given as Vector4, matrix as pointer.
[AI] Sets this vector as the product of another Vector4 and a 4x4 matrix.
p_a | Vector4 to multiply. [AI] |
p_b | Matrix pointer. [AI] |
Calls SetMatrixProduct with the internal data of p_a.
p_a | The input Vector4. [AI] |
p_b | Pointer to a flat array of 16 floats representing a 4x4 matrix. [AI] |
|
inlineoverrideprotectedvirtual |
[AI] Subtracts the vector specified by p_value from this vector.
[AI] Subtracts the elements of a float array from the vector's components.
[AI] Subtracts a 2D float array from the vector data in-place.
p_value | Pointer to array to subtract. [AI] |
p_value | Pointer to a float array containing the values to subtract. |
[AI] Each component of the input array is subtracted from the corresponding component of the vector. The length must be 2.
Performs component-wise subtraction for x,y,z (via Vector3::SubImpl) and then subtracts the fourth element from w.
p_value | Array of at least four floats to subtract. [AI] |
Reimplemented from Vector3.
|
friend |