3 dimensional floating point vector More...
Public Member Functions | |
void | Zero (void) noexcept |
Set all values to zero. | |
void | One (void) noexcept |
Set all values to 1.0f. | |
float | GetX (void) const noexcept |
Return the x component of the vector. | |
float | GetY (void) const noexcept |
Return the y component of the vector. | |
float | GetZ (void) const noexcept |
Return the z component of the vector. | |
void | SetX (float fX) noexcept |
Set the x component of the vector. | |
void | SetY (float fY) noexcept |
Set the y component of the vector. | |
void | SetZ (float fZ) noexcept |
Set the z component of the vector. | |
void | Set (float fInput) noexcept |
Set all of the members to specific value. | |
void | Set (float fX, float fY) noexcept |
Set the values to specific values. | |
void | Set (float fX, float fY, float fZ) noexcept |
Set the values to specific values. | |
void | Set (const Vector3D_t *pInput) noexcept |
Copy a Vector3D_t. | |
void | Set (const FixedVector3D_t *pInput) noexcept |
Convert a fixed point vector into a floating point vector. | |
void | Negate (void) noexcept |
Negate a 3D vector. | |
void | Negate (float fX, float fY, float fZ) noexcept |
Negate the input and store it in this structure. | |
void | Negate (const Vector3D_t *pInput) noexcept |
Make a copy of the input after it's been negated. | |
void | Interpolate (const Vector3D_t *pFrom, const Vector3D_t *pTo, float fFactor) noexcept |
Interpolate between two vectors. | |
float | Dot (float fX, float fY, float fZ) const noexcept |
Return a dot product of two 3D vectors. | |
float | Dot (const Vector3D_t *pInput) const noexcept |
Return a dot product of two 3D vectors. | |
void | Add (const Vector3D_t *pInput) noexcept |
Add another vector to this one. | |
void | Add (float fInput) noexcept |
Add the same scalar value to each of member values. | |
void | Add (const Vector3D_t *pInput1, const Vector3D_t *pInput2) noexcept |
Add two vectors and store the result in this vector. | |
void | Add (const Vector3D_t *pInput, float fInput) noexcept |
Add a vector and a scalar to every member of the vector and store the result in this vector. | |
void | Sub (const Vector3D_t *pInput) noexcept |
Subtract another vector from this one. | |
void | Sub (float fInput) noexcept |
Subtract the same scalar value from each of member values. | |
void | Sub (const Vector3D_t *pInput1, const Vector3D_t *pInput2) noexcept |
Subtract two vectors and store the result in this vector. | |
void | Sub (const Vector3D_t *pInput, float fInput) noexcept |
Subract a vector and a scalar to every member of the vector and store the result in this vector. | |
void | Mul (const Vector3D_t *pInput) noexcept |
Multiply another vector to this one. | |
void | Mul (float fInput) noexcept |
Multiply the same scalar value to each of member values. | |
void | Mul (const Vector3D_t *pInput1, const Vector3D_t *pInput2) noexcept |
Multiply two vectors and store the result in this vector. | |
void | Mul (const Vector3D_t *pInput, float fInput) noexcept |
Multiply a vector and a scalar to every member of the vector and store the result in this vector. | |
void | MulAdd (const Vector3D_t *pMul, const Vector3D_t *pAdd) noexcept |
Multiply two vectors and add a third and store the result in this vector. | |
void | MulAdd (const Vector3D_t *pMul1, const Vector3D_t *pMul2, const Vector3D_t *pAdd) noexcept |
Multiply two vectors and add a third and store the result in this vector. | |
void | MulAdd (float fInput, const Vector3D_t *pAdd) noexcept |
Multiply this vector by a scalar and add a second vector and store the result in this vector. | |
void | MulAdd (const Vector3D_t *pMul, float fInput, const Vector3D_t *pAdd) noexcept |
Multiply a vector by a scalar and add a second vector and store the result in this vector. | |
void | Cross (const Vector3D_t *pInput) noexcept |
Return a cross product of two 3D vectors. | |
void | Cross (const Vector3D_t *pInput1, const Vector3D_t *pInput2) noexcept |
Return a cross product of two 3D vectors. | |
float | GetLengthSquared (void) const noexcept |
Returns the square of the length of a 3D vector. | |
float | GetLength (void) const noexcept |
Return the length of a vector (High precision) | |
float | GetLengthFast (void) const noexcept |
Return the length of a vector (Good precision) | |
void | SetLength (float fInput) noexcept |
Normalize a 3D vector to a specific length (High precision) | |
void | SetLengthFast (float fInput) noexcept |
Normalize a 3D vector to a specific length (Good precision) | |
float | GetDistanceSquared (float fX, float fY, float fZ) const noexcept |
Returns the square of the distance between two 3D points. | |
float | GetDistanceSquared (const Vector3D_t *pInput) const noexcept |
Returns the square of the distance between two 3D points. | |
float | GetDistance (float fX, float fY, float fZ) const noexcept |
Returns the square of the distance between two 3D points. | |
float | GetDistance (const Vector3D_t *pInput) const noexcept |
Returns the square of the distance between two 3D points. | |
float | GetDistanceFast (float fX, float fY, float fZ) const noexcept |
Returns the square of the distance between two 3D points (Good precision). | |
float | GetDistanceFast (const Vector3D_t *pInput) const noexcept |
Returns the square of the distance between two 3D points (Good precision). | |
void | Normalize (void) noexcept |
Normalize a 3D vector. | |
void | Normalize (float fX, float fY, float fZ) noexcept |
Copy a normalized 3D vector. | |
void | Normalize (const Vector3D_t *pInput) noexcept |
Copy a normalized 3D vector. | |
void | PlaneNormal (const Vector3D_t *pOrigin, const Vector3D_t *pPoint1, const Vector3D_t *pPoint2) noexcept |
Calculate Plane Normal from three points on plane's. | |
void | NormalizeFast (void) noexcept |
Normalize a 3D vector (Good precision) | |
void | NormalizeFast (float fX, float fY, float fZ) noexcept |
Copy a normalized 3D vector. | |
void | NormalizeFast (const Vector3D_t *pInput) noexcept |
Copy a normalized 3D vector. | |
uint_t | Equal (const Vector3D_t *pInput) const noexcept |
Check if two vectors are equal. | |
uint_t | Equal (const Vector3D_t *pInput, float fRange) const noexcept |
Check if two vectors are equal within an epsilon range. | |
uint_t | BitwiseEqual (const Vector3D_t *pInput) const noexcept |
Compare two Vector3D_t's for bitwise equality. | |
float & | operator[] (uintptr_t uInput) noexcept |
Access the members as an array. | |
const float & | operator[] (uintptr_t uInput) const noexcept |
Access the members as an array. | |
uint_t | operator== (const Vector3D_t &rInput) const noexcept |
Compare two Vector3D_t's for equality. | |
uint_t | operator!= (const Vector3D_t &rInput) const noexcept |
Compare two Vector3D_t's for inequality. | |
operator const float * () const noexcept | |
Convert to a const float pointer. | |
Public Attributes | |
float | x |
32 bit floating point X value for the 3D Vector | |
float | y |
32 bit floating point Y value for the 3D Vector | |
float | z |
32 bit floating point Z value for the 3D Vector | |
3 dimensional floating point vector
This 12 byte vector contains x,y and z 32 bit floating point coordinates. A set of common functions for simple 3 dimensional math are part of the structure.
It is expected to be 4 byte aligned and use scalar math. The members are hard coded to be "x", "y" and "z" for maximum compatibility
|
inlinenoexcept |
Add another vector to this one.
pInput | Vector to add |
|
inlinenoexcept |
Add a vector and a scalar to every member of the vector and store the result in this vector.
Initialize this vector with the result of the addition of the input vector and a scalar applied to every member.
pInput | Vector to add the scalar to |
fInput | Scalar to add to the vector |
|
inlinenoexcept |
Add two vectors and store the result in this vector.
Initialize this vector with the result of the addition of the two input vectors.
pInput1 | First vector to add |
pInput2 | Second vector to add |
Add the same scalar value to each of member values.
fInput | Value to add |
|
noexcept |
Compare two Vector3D_t's for bitwise equality.
Unlike operator==(const Vector3D_t &) const, this function performs a bitwise comparison, which in some cases is faster if pure equality detection is desired.
pInput | Pointer to the Vector3D_t to compare against |
|
noexcept |
Return a cross product of two 3D vectors.
Calculate the cross product between two 3D vectors. The end result is the perpendicular vector
x | y | z |
---|---|---|
(y * pInput->z) - (z * pInput->y) | (z * pInput->x) - (x * pInput->z) | (x * pInput->y) - (y * pInput->x) |
pInput | Valid pointer to a Vector3D_t structure to perform a cross product against |
|
noexcept |
Return a cross product of two 3D vectors.
Calculate the cross product between two 3D vectors. The end result is the perpendicular vector stored in this Vector3D_t instance.
x | y | z |
---|---|---|
(pInput1->y * pInput2->z) - (pInput1->z * pInput2->y) | (pInput1->z * pInput2->x) - (pInput1->x * pInput2->z) | (pInput1->x * pInput2->y) - (pInput1->y * pInput2->x) |
pInput1 | Valid pointer to a Vector3D_t structure to perform a cross product from |
pInput2 | Valid pointer to a Vector3D_t structure to perform a cross product against |
|
inlinenoexcept |
Return a dot product of two 3D vectors.
pInput | Valid pointer to a Vector3D_t structure to perform a dot product against |
Return a dot product of two 3D vectors.
fX | X value to dot against |
fY | Y value to dot against |
fZ | Z value to dot against |
|
noexcept |
Check if two vectors are equal.
Perform a binary compare of two vectors for equality.
pInput | Vector to compare against |
|
noexcept |
Check if two vectors are equal within an epsilon range.
Perform a difference of each member and if they are less than a specific range, return TRUE for equality
pInput | Vector to compare against |
fRange | Epsilon range to use for equality |
|
noexcept |
Returns the square of the distance between two 3D points.
Create a vector from the difference of two 3D points and return the vector's length
pInput | Valid pointer to a Vector3D_t structure that contains the other 3D point |
|
noexcept |
Returns the square of the distance between two 3D points.
Create a vector from the difference of two 3D points and return the vector's length
fX | X value of the other 3D point |
fY | Y value of the other 3D point |
fZ | Z value of the other 3D point |
|
noexcept |
Returns the square of the distance between two 3D points (Good precision).
Create a vector from the difference of two 3D points and return the vector's length
On some systems, lower precision instructions are used to increase speed at the cost of precision. If the calculation doesn't rely on high precision, use this function for higher performance
pInput | Valid pointer to a Vector3D_t structure that contains the other 3D point |
|
noexcept |
Returns the square of the distance between two 3D points (Good precision).
Create a vector from the difference of two 3D points and return the vector's length
On some systems, lower precision instructions are used to increase speed at the cost of precision. If the calculation doesn't rely on high precision, use this function for higher performance
fX | X value of the other 3D point |
fY | Y value of the other 3D point |
fZ | Z value of the other 3D point |
|
noexcept |
Returns the square of the distance between two 3D points.
Create a vector from the difference of two 3D points and return the vector's length squared
pInput | Valid pointer to a Vector3D_t structure that contains the other 3D point |
|
noexcept |
Returns the square of the distance between two 3D points.
Create a vector from the difference of two 3D points and return the vector's length squared
fX | X value of the other 3D point |
fY | Y value of the other 3D point |
fZ | Z value of the other 3D point |
Return the length of a vector (High precision)
Return the length of a vector (Good precision)
On some systems, lower precision instructions are used to increase speed at the cost of precision. If the calculation doesn't rely on high precision, use this function for higher performance
Returns the square of the length of a 3D vector.
|
noexcept |
Interpolate between two vectors.
Given a factor between 0.0f and 1.0f inclusive, perform a linear scale between the two vectors and return pFrom if the factor is 0.0f and pTo if the factor is 1.0f
No clamping is performed.
pFrom | Valid pointer to a Vector3D_t structure for a factor of 0.0f |
pTo | Valid pointer to a Vector3D_t structure for a factor of 1.0f |
fFactor | Scale value between 0.0f and 1.0f inclusive |
|
inlinenoexcept |
Multiply another vector to this one.
pInput | Vector to multiply |
|
inlinenoexcept |
Multiply a vector and a scalar to every member of the vector and store the result in this vector.
Initialize this vector with the result of the multiplication of the input vector and a scalar applied to every member.
pInput | Vector to multiply the scalar to |
fInput | Scalar to multiply to the vector |
|
inlinenoexcept |
Multiply two vectors and store the result in this vector.
Initialize this vector with the result of the multiplication of the two input vectors.
pInput1 | First vector to multiply |
pInput2 | Second vector to multiply |
Multiply the same scalar value to each of member values.
fInput | Value to multiply |
|
inlinenoexcept |
Multiply two vectors and add a third and store the result in this vector.
Initialize this vector with the result of the multiplication of this vector and pMul and add the vector pAdd
this = (this*pMul)+pAdd;
pMul | Vector to multiply |
pAdd | Vector to add |
|
inlinenoexcept |
Multiply a vector by a scalar and add a second vector and store the result in this vector.
Initialize this vector with the result of the multiplication of a vector and a scalar and add the vector pAdd
this = (pMul*fInput)+pAdd;
pMul | Vector to multiply |
fInput | Scalar to multiply by all members of the vector pMul |
pAdd | Vector to add |
|
inlinenoexcept |
Multiply two vectors and add a third and store the result in this vector.
Initialize this vector with the result of the multiplication of two vectors and add the vector pAdd
this = (pMul1*pMu2)+pAdd;
pMul1 | First vector to multiply |
pMul2 | Second vector to multiply |
pAdd | Vector to add |
|
inlinenoexcept |
Multiply this vector by a scalar and add a second vector and store the result in this vector.
Initialize this vector with the result of the multiplication of a vector and a scalar and add the vector pAdd
this = (this*fInput)+pAdd;
fInput | Scalar to multiply by all members of this vector |
pAdd | Vector to add |
|
inlinenoexcept |
Make a copy of the input after it's been negated.
Copy the input data and negate it.
pInput | Valid pointer to a Vector3D_t structure to copy and negate |
Negate the input and store it in this structure.
Set the x,y and z values to -fX,-fY and -fZ respectively
fX | X value to negate |
fY | Y value to negate |
fZ | Z value to negate |
Negate a 3D vector.
Set the x,y and z values to -x,-y and -z respectively
|
noexcept |
Copy a normalized 3D vector.
Make a copy of a 3D vector and set the copy's length to 1.0f
pInput | Valid pointer to a Vector3D_t structure that will be copied and normalize |
|
noexcept |
Copy a normalized 3D vector.
Make a copy of a 3D vector and set the copy's length to 1.0f
fX | X value of the 3D vector to normalize |
fY | Y value of the 3D vector to normalize |
fZ | Z value of the 3D vector to normalize |
|
noexcept |
Normalize a 3D vector.
Set the 3D vector's length to 1.0f
|
noexcept |
Copy a normalized 3D vector.
Make a copy of a 3D vector and set the copy's length to 1.0f
On some systems, lower precision instructions are used to increase speed at the cost of precision. If the calculation doesn't rely on high precision, use this function for higher performance
pInput | Valid pointer to a Vector3D_t structure that will be copied and normalize |
|
noexcept |
Copy a normalized 3D vector.
Make a copy of a 3D vector and set the copy's length to 1.0f
On some systems, lower precision instructions are used to increase speed at the cost of precision. If the calculation doesn't rely on high precision, use this function for higher performance
fX | X value of the 3D vector to normalize |
fY | Y value of the 3D vector to normalize |
fZ | Z value of the 3D vector to normalize |
|
noexcept |
Normalize a 3D vector (Good precision)
Set the 3D vector's length to 1.0f
On some systems, lower precision instructions are used to increase speed at the cost of precision. If the calculation doesn't rely on high precision, use this function for higher performance
Convert to a const float pointer.
This convenience operator converts the Vector3D_t into a float pointer to pass to other APIs that treat this as an array of 32 bit floats.
|
inlinenoexcept |
Compare two Vector3D_t's for inequality.
rInput | Reference to the Vector3D_t to compare against |
|
inlinenoexcept |
Compare two Vector3D_t's for equality.
rInput | Reference to the Vector3D_t to compare against |
Access the members as an array.
uInput | 0 for x, 1 for y, 2 for z, any other value is an error |
Access the members as an array.
uInput | 0 for x, 1 for y, 2 for z, any other value is an error |
|
noexcept |
Calculate Plane Normal from three points on plane's.
The three input vectors are treated as points on a single plane and are used to make two vectors which a cross product is applied to create the normal.
pOrigin | Pointer to the origin point on the plane |
pPoint1 | Pointer to the first ray endpoint |
pPoint2 | Pointer to the second ray endpoint |
|
noexcept |
Convert a fixed point vector into a floating point vector.
pInput | Valid pointer to a FixedVector3D_t structure to copy |
|
inlinenoexcept |
Copy a Vector3D_t.
Make a copy of a Vector3D_t
pInput | Valid pointer to a Vector3D_t structure to copy |
Set all of the members to specific value.
Sets the x,y and z values to a specific value
fInput | New value for all members |
Set the values to specific values.
Sets the x and y values to specific values. z is set to 0.0f
fX | New x value |
fY | New y value |
Set the values to specific values.
Sets the x, y and z values to specific values.
fX | New x value |
fY | New y value |
fZ | New z value |
|
noexcept |
Normalize a 3D vector to a specific length (High precision)
Set the 3D vector's length to fInput
fInput | Length to set the vector to |
|
noexcept |
Normalize a 3D vector to a specific length (Good precision)
Set the 3D vector's length to fInput
On some systems, lower precision instructions are used to increase speed at the cost of precision. If the calculation doesn't rely on high precision, use this function for higher performance
fInput | Length to set the vector to |
Set the x component of the vector.
fX | The new x component of the vector. |
Set the y component of the vector.
fY | The new y component of the vector. |
Set the z component of the vector.
fZ | The new z component of the vector. |
|
inlinenoexcept |
Subtract another vector from this one.
pInput | Vector to subtract |
|
inlinenoexcept |
Subract a vector and a scalar to every member of the vector and store the result in this vector.
Initialize this vector with the result of the subtraction of the input vector and a scalar applied to every member.
pInput | Vector to subract the scalar from |
fInput | Scalar to subtract from the vector |
|
inlinenoexcept |
Subtract two vectors and store the result in this vector.
Initialize this vector with the result of the subtraction of the two input vectors.
pInput1 | First vector to subtract from |
pInput2 | Second vector to subtract with |
Subtract the same scalar value from each of member values.
fInput | Value to subtract |
float Burger::Vector3D_t::x |
32 bit floating point X value for the 3D Vector
float Burger::Vector3D_t::y |
32 bit floating point Y value for the 3D Vector
float Burger::Vector3D_t::z |
32 bit floating point Z value for the 3D Vector