2 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. | |
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 | 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 (const Vector2D_t *pInput) noexcept |
Copy a Vector2D_t. | |
void | Set (const FixedVector2D_t *pInput) noexcept |
Convert a fixed point vector into a floating point vector. | |
void | Negate (void) noexcept |
Negate a 2D vector. | |
void | Negate (float fX, float fY) noexcept |
Negate the input and store it in this structure. | |
void | Negate (const Vector2D_t *pInput) noexcept |
Make a copy of the input after it's been negated. | |
void | Interpolate (const Vector2D_t *pFrom, const Vector2D_t *pTo, float fFactor) noexcept |
Interpolate between two vectors. | |
float | Dot (float fX, float fY) const noexcept |
Return a dot product of two 2D vectors. | |
float | Dot (const Vector2D_t *pInput) const noexcept |
Return a dot product of two 2D vectors. | |
void | Add (const Vector2D_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 Vector2D_t *pInput1, const Vector2D_t *pInput2) noexcept |
Add two vectors and store the result in this vector. | |
void | Add (const Vector2D_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 Vector2D_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 Vector2D_t *pInput1, const Vector2D_t *pInput2) noexcept |
Subtract two vectors and store the result in this vector. | |
void | Sub (const Vector2D_t *pInput, float fInput) noexcept |
Subtract a vector and a scalar to every member of the vector and store the result in this vector. | |
void | Mul (const Vector2D_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 Vector2D_t *pInput1, const Vector2D_t *pInput2) noexcept |
Multiply two vectors and store the result in this vector. | |
void | Mul (const Vector2D_t *pInput, float fInput) noexcept |
Multiply a vector and a scalar to every member of the vector and store the result in this vector. | |
float | Cross (float fX, float fY) const noexcept |
Return a cross product of two 2D vectors. | |
float | Cross (const Vector2D_t *pInput) const noexcept |
Return a cross product of two 2D vectors. | |
float | GetLengthSquared (void) const noexcept |
Returns the square of the length of a 2D 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 2D vector to a specific length (High precision) | |
void | SetLengthFast (float fInput) noexcept |
Normalize a 2D vector to a specific length (Good precision) | |
float | GetDistanceSquared (float fX, float fY) const noexcept |
Returns the square of the distance between two 2D points. | |
float | GetDistanceSquared (const Vector2D_t *pInput) const noexcept |
Returns the square of the distance between two 2D points. | |
float | GetDistance (float fX, float fY) const noexcept |
Returns the square of the distance between two 2D points. | |
float | GetDistance (const Vector2D_t *pInput) const noexcept |
Returns the square of the distance between two 2D points. | |
float | GetDistanceFast (float fX, float fY) const noexcept |
Returns the square of the distance between two 2D points (Good precision). | |
float | GetDistanceFast (const Vector2D_t *pInput) const noexcept |
Returns the square of the distance between two 2D points (Good precision). | |
void | Normalize (void) noexcept |
Normalize a 2D vector. | |
void | Normalize (float fX, float fY) noexcept |
Copy a normalized 2D vector. | |
void | Normalize (const Vector2D_t *pInput) noexcept |
Copy a normalized 2D vector. | |
void | NormalizeFast (void) noexcept |
Normalize a 2D vector (Good precision) | |
void | NormalizeFast (float fX, float fY) noexcept |
Copy a normalized 2D vector. | |
void | NormalizeFast (const Vector2D_t *pInput) noexcept |
Copy a normalized 2D vector. | |
uint_t | BitwiseEqual (const Vector2D_t *pInput) const noexcept |
Compare two Vector2D_t's for bitwise equality. | |
float | Determinant (const Vector2D_t *pInput1, const Vector2D_t *pInput2) const noexcept |
Calculate the determinant between three points. | |
uint_t | IsPointInTriangle (const Vector2D_t *pVertex1, const Vector2D_t *pVertex2, const Vector2D_t *pVertex3) const noexcept |
Determine if a point is inside of a triangle. | |
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 Vector2D_t &rInput) const noexcept |
Compare two Vector2D_t's for equality. | |
uint_t | operator!= (const Vector2D_t &rInput) const noexcept |
Compare two Vector2D_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 2D Vector | |
float | y |
32 bit floating point Y value for the 2D Vector | |
2 dimensional floating point vector
This 8 byte vector contains x and y 32 bit floating point coordinates. A set of common functions for simple 2 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" and "y" 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 |
|
inlinenoexcept |
Add the same scalar value to each of member values.
fInput | Value to add |
|
noexcept |
Compare two Vector2D_t's for bitwise equality.
Unlike operator==(const Vector2D_t &) const, this function performs a bitwise comparison, which in some cases is faster if pure equality detection is desired.
pInput | Pointer to the Vector2D_t to compare against |
|
inlinenoexcept |
Return a cross product of two 2D vectors.
Calculate the cross product between two 2D vectors as if they were two 3D vectors and the z components were zero. The end result is the new z component for the perpendicular vector
pInput | Valid pointer to a Vector2D_t structure to perform a cross product against |
|
inlinenoexcept |
Return a cross product of two 2D vectors.
Calculate the cross product between two 2D vectors as if they were two 3D vectors and the z components were zero. The end result is the new z component for the perpendicular vector
fX | X value to cross against |
fY | Y value to cross against |
|
inlinenoexcept |
Calculate the determinant between three points.
Using the formula ((pInput1->x-x) * (pInput2->y-y)) - ((pInput1->y-y) * (pInput2->x-x)), calculate the determinant and return the result. Used for determining if a point is on a side of a vector or on the vector.
pInput1 | Pointer to the point that produces the primary vector. |
pInput2 | Pointer to the point that produces the vector to test with. |
|
inlinenoexcept |
Return a dot product of two 2D vectors.
pInput | Valid pointer to a Vector2D_t structure to perform a dot product against |
|
inlinenoexcept |
Return a dot product of two 2D vectors.
fX | X value to dot against |
fY | Y value to dot against |
|
noexcept |
Returns the square of the distance between two 2D points.
Create a vector from the difference of two 2D points and return the vector's length
pInput | Valid pointer to a Vector2D_t structure that contains the other 2D point |
|
noexcept |
Returns the square of the distance between two 2D points.
Create a vector from the difference of two 2D points and return the vector's length
fX | X value of the other 2D point |
fY | Y value of the other 2D point |
|
noexcept |
Returns the square of the distance between two 2D points (Good precision).
Create a vector from the difference of two 2D 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 Vector2D_t structure that contains the other 2D point |
|
noexcept |
Returns the square of the distance between two 2D points (Good precision).
Create a vector from the difference of two 2D 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 2D point |
fY | Y value of the other 2D point |
|
noexcept |
Returns the square of the distance between two 2D points.
Create a vector from the difference of two 2D points and return the vector's length squared
pInput | Valid pointer to a Vector2D_t structure that contains the other 2D point |
|
noexcept |
Returns the square of the distance between two 2D points.
Create a vector from the difference of two 2D points and return the vector's length squared
fX | X value of the other 2D point |
fY | Y value of the other 2D point |
|
inlinenoexcept |
Return the length of a vector (High precision)
|
inlinenoexcept |
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
|
inlinenoexcept |
Returns the square of the length of a 2D vector.
|
inlinenoexcept |
Return the x component of the vector.
|
inlinenoexcept |
Return the y component of the 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 Vector2D_t structure for a factor of 0.0f |
pTo | Valid pointer to a Vector2D_t structure for a factor of 1.0f |
fFactor | Scale value between 0.0f and 1.0f inclusive |
|
noexcept |
Determine if a point is inside of a triangle.
Test the point against the three arcs generated by the three triangle points and if the point is within all of the arcs, return TRUE since the point is inside the triangle.
pVertex1 | Pointer to the first vertex of the triangle. |
pVertex2 | Pointer to the second vertex of the triangle. |
pVertex3 | Pointer to the third vertex of the triangle. |
|
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 |
|
inlinenoexcept |
Multiply the same scalar value to each of member values.
fInput | Value to multiply |
|
inlinenoexcept |
Make a copy of the input after it's been negated.
Copy the input data and negate it.
pInput | Valid pointer to a Vector2D_t structure to copy and negate |
|
inlinenoexcept |
Negate the input and store it in this structure.
Set the x and y value to -fX and -fY respectively
fX | X value to negate |
fY | Y value to negate |
|
inlinenoexcept |
Negate a 2D vector.
Set the x and y value to -x and -y respectively
|
noexcept |
Copy a normalized 2D vector.
Make a copy of a 2D vector and set the copy's length to 1.0f
pInput | Valid pointer to a Vector2D_t structure that will be copied and normalize |
|
noexcept |
Copy a normalized 2D vector.
Make a copy of a 2D vector and set the copy's length to 1.0f
fX | X value of the 2D vector to normalize |
fY | Y value of the 2D vector to normalize |
|
noexcept |
Normalize a 2D vector.
Set the 2D vector's length to 1.0f
|
noexcept |
Copy a normalized 2D vector.
Make a copy of a 2D 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 Vector2D_t structure that will be copied and normalize |
|
noexcept |
Copy a normalized 2D vector.
Make a copy of a 2D 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 2D vector to normalize |
fY | Y value of the 2D vector to normalize |
|
noexcept |
Normalize a 2D vector (Good precision)
Set the 2D 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
|
inlinenoexcept |
|
inlinenoexcept |
Convert to a const float pointer.
This convenience operator converts the Vector2D_t into a float pointer to pass to other APIs that treat this as an array of 32 bit floats.
|
inlinenoexcept |
Compare two Vector2D_t's for inequality.
rInput | Reference to the Vector2D_t to compare against |
|
inlinenoexcept |
Compare two Vector2D_t's for equality.
rInput | Reference to the Vector2D_t to compare against |
|
inlinenoexcept |
Access the members as an array.
uInput | 0 for x or 1 for y, any other value is an error |
|
inlinenoexcept |
Access the members as an array.
uInput | 0 for x or 1 for y, any other value is an error |
|
noexcept |
Convert a fixed point vector into a floating point vector.
pInput | Valid pointer to a FixedVector2D_t structure to copy |
|
inlinenoexcept |
Copy a Vector2D_t.
Make a copy of a Vector2D_t
pInput | Valid pointer to a Vector2D_t structure to copy |
|
inlinenoexcept |
Set all of the members to specific value.
Sets the x and y values to a specific value
fInput | New value for all members |
|
inlinenoexcept |
Set the values to specific values.
Sets the x and y values to specific values
fX | New x value |
fY | New y value |
|
noexcept |
Normalize a 2D vector to a specific length (High precision)
Set the 2D vector's length to fInput
fInput | Length to set the vector to |
|
noexcept |
Normalize a 2D vector to a specific length (Good precision)
Set the 2D 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 |
|
inlinenoexcept |
Set the x component of the vector.
fX | The new x component of the vector. |
|
inlinenoexcept |
Set the y component of the vector.
fY | The new y component of the vector. |
|
inlinenoexcept |
Subtract another vector from this one.
pInput | Vector to subtract |
|
inlinenoexcept |
Subtract 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 subtract 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 |
|
inlinenoexcept |
Subtract the same scalar value from each of member values.
fInput | Value to subtract |
|
inlinenoexcept |
float Burger::Vector2D_t::x |
32 bit floating point X value for the 2D Vector
float Burger::Vector2D_t::y |
32 bit floating point Y value for the 2D Vector