Contains objects and functions for dealing with Vector and Matrix math. More...
Classes | |
class | AngleType |
class | Matrix3 |
class | Matrix4 |
class | Vector2 |
class | Vector3 |
class | Vector4 |
Typedefs | |
typedef AngleType< float > | Angle |
Enumerations | |
enum | AngleUnit { AngleUnit::Degrees, AngleUnit::Radians } |
enum | ColumnMajorMatrix { ColumnMajor = 1 } |
enum | SkipInitialization { kSkipInitialization = 0 } |
enum | VectorComponent { kComponentX = 0, kComponentY, kComponentZ, kComponentW } |
Functions | |
template<typename Type > | |
constexpr Type | Pi (void) |
template<typename Type > | |
constexpr Type | TwoPi (void) |
static const float | kTolerance (0.00001f) |
const float | kPoundsToKilograms (0.45359237f) |
A constant for the conversion of 1 pound (lb) to 1 kilogram (kg). | |
const float | kKilogramsToPounds (1.0f/kPoundsToKilograms) |
A constant for the conversion of 1 kilogram (kg) to 1 pound (lb). | |
const float | kInchesToMeters (0.0254f) |
A constant for the distance conversion of 1 inch to 1 meter. | |
const float | kMetersToInches (1.0f/kInchesToMeters) |
A constant for the distance conversion of 1 meter to 1 inch. | |
const float | kFeetToMeters (0.3048f) |
A constant for the distance conversion from 1 foot to 1 meter. | |
const float | kMetersToFeet (1.0f/kFeetToMeters) |
A constant for the distance conversion from 1 meter to 1 foot. | |
const float | kMilesToKilometers (1.609344f) |
A constant for the distance conversion from 1 mile to 1 kilometer. | |
const float | kKilometersToMiles (1.0f/kMilesToKilometers) |
A constant for the distance conversion from 1 kilometer to 1 mile. | |
const float | kFootPoundsToNewtonMeters (0.73756214837f) |
A constant for the torque in ft-lbs to Nm. | |
const float | kNewtonMetersToFootPounds (1.0f/kFootPoundsToNewtonMeters) |
A constant for the torque conversion from Nm to ft-lbs. | |
template<typename Type > | |
bool | IsEqual (const Type &leftValue, const Type &rightValue) |
bool | IsEqual (const float leftValue, const float rightValue, const float tolerance=tbMath::kTolerance) |
bool | IsEqual (const double leftValue, const double rightValue, const double tolerance=tbMath::kTolerance) |
template<typename Type > | |
bool | IsZero (const Type &value) |
bool | IsZero (const float value, const float tolerance=tbMath::kTolerance) |
bool | IsZero (const double value, const double tolerance=tbMath::kTolerance) |
template<typename T > | |
constexpr const T & | Maximum (const T &leftValue, const T &rightValue) noexcept |
template<typename T > | |
constexpr const T & | Minimum (const T &leftValue, const T &rightValue) noexcept |
template<typename T > | |
constexpr const T & | Clamp (const T &value, const T &minimumValue, const T &maximumValue) noexcept |
Vector3 * | Vector3MatrixMultiply (Vector3 *result, const Vector3 *inputVector, const Matrix3 *inputMatrix) |
Vector3 * | MatrixVector3Multiply (Vector3 *result, const Matrix3 *inputMatrix, const Vector3 *inputVector) |
Matrix3 * | MatrixMultiply (Matrix3 *result, const Matrix3 *left, const Matrix3 *right) |
Matrix4 * | MatrixMultiply (Matrix4 *result, const Matrix4 *leftSide, const Matrix4 *rightSide) |
Matrix3 * | MatrixMultiply (Matrix3 *result, const Matrix3 *input, const float scalar) |
Matrix4 * | MatrixMultiply (Matrix4 *result, const Matrix4 *input, const float scalar) |
Matrix3 * | MatrixComputeInverse (Matrix3 *result, const Matrix3 *input) |
Matrix4 * | MatrixComputeInverse (Matrix4 *result, const Matrix4 *input) |
Matrix3 * | MatrixFastInverse (Matrix3 *result, const Matrix3 *input) |
Matrix4 * | MatrixFastInverse (Matrix4 *result, const Matrix4 *input) |
Vector3 * | Vector3TransformCoordinate (Vector3 *result, const Vector3 *inputVector, const Matrix4 *inputMatrix) |
Vector3 * | Vector3TransformNormal (Vector3 *result, const Vector3 *inputVector, const Matrix4 *inputMatrix) |
Vector4 * | Vector4MatrixMultiply (Vector4 *result, const Vector4 *inputVector, const Matrix4 *inputMatrix) |
Vector4 * | MatrixVector4Multiply (Vector4 *result, const Matrix4 *inputMatrix, const Vector4 *inputVector) |
Matrix4 * | MatrixCreateTranslation (Matrix4 *result, const Vector3 *translation) |
Matrix4 * | MatrixCreateTranslation (Matrix4 *result, const float translationX, const float translationY, const float translationZ) |
Matrix3 * | MatrixCreateScale (Matrix3 *result, const Vector3 *scale) |
Matrix4 * | MatrixCreateScale (Matrix4 *result, const Vector3 *scale) |
Matrix3 * | MatrixCreateScale (Matrix3 *result, const float scaleX, const float scaleY, const float scaleZ) |
Matrix4 * | MatrixCreateScale (Matrix4 *result, const float scaleX, const float scaleY, const float scaleZ) |
Matrix3 * | MatrixCreateRotationX (Matrix3 *result, const Angle rotation) |
Matrix4 * | MatrixCreateRotationX (Matrix4 *result, const Angle rotation) |
Matrix3 * | MatrixCreateRotationY (Matrix3 *result, const Angle rotation) |
Matrix4 * | MatrixCreateRotationY (Matrix4 *result, const Angle rotation) |
Matrix3 * | MatrixCreateRotationZ (Matrix3 *result, const Angle rotation) |
Matrix4 * | MatrixCreateRotationZ (Matrix4 *result, const Angle rotation) |
Matrix3 * | MatrixCreateRotationA (Matrix3 *result, const Vector3 *rotationAxis, const Angle rotation) |
Matrix4 * | MatrixCreateRotationA (Matrix4 *result, const Vector3 *rotationAxis, const Angle rotation) |
Matrix3 * | MatrixCreateIdentity (Matrix3 *result) |
Matrix4 * | MatrixCreateIdentity (Matrix4 *result) |
Matrix4 * | MatrixCreateLookAt (Matrix4 *result, const Vector3 &eyePosition, const Vector3 &targetPosition, const Vector3 &unitUp) |
Matrix4 * | MatrixCreatePerspectiveRH (Matrix4 *result, const float fieldOfView, const float aspectRatio, const float nearPlane, const float farPlane) |
Matrix4 * | MatrixCreatePerspectiveLH (Matrix4 *result, const float fieldOfView, const float aspectRatio, const float nearPlane, const float farPlane) |
Matrix4 * | MatrixCreateOrthoRH (Matrix4 *result, const float left, const float right, const float top, const float bottom, const float nearPlane, const float farPlane) |
Matrix4 * | MatrixCreateOrthoLH (Matrix4 *result, const float left, const float right, const float top, const float bottom, const float nearPlane, const float farPlane) |
Matrix3 * | MatrixAdd (Matrix3 *result, const Matrix3 *leftSide, const Matrix3 *rightSide) |
Matrix4 * | MatrixAdd (Matrix4 *result, const Matrix4 *leftSide, const Matrix4 *rightSide) |
Matrix3 * | MatrixSubtract (Matrix3 *result, const Matrix3 *leftSide, const Matrix3 *rightSide) |
Matrix4 * | MatrixSubtract (Matrix4 *result, const Matrix4 *leftSide, const Matrix4 *rightSide) |
Matrix3 * | MatrixTranspose (Matrix3 *result, const Matrix3 *input) |
Matrix4 * | MatrixTranspose (Matrix4 *result, const Matrix4 *input) |
float | Matrix2x2Determinant (const float f11, const float f12, const float f21, const float f22) |
float | Matrix3x3Determinant (const float f11, const float f12, const float f13, const float f21, const float f22, const float f23, const float f31, const float f32, const float f33) |
float | MatrixDeterminant (const Matrix3 *input) |
float | MatrixDeterminant (const Matrix4 *input) |
unsigned int | SeedRandomGenerator (void) |
unsigned int | SeedRandomGenerator (const tbCore::tbString &seed) |
void | SeedRandomGenerator (unsigned int seed) |
int | RandomInt (void) |
int | RandomInt (const int minimumValue, const int maximumValue) |
float | RandomFloat (void) |
float | RandomFloat (const float minimumValue, const float maximumValue) |
Vector2 * | Vector2Add (Vector2 *result, const Vector2 *leftSide, const Vector2 *rightSide) |
Vector3 * | Vector3Add (Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide) |
Vector4 * | Vector4Add (Vector4 *result, const Vector4 *leftSide, const Vector4 *rightSide) |
Vector2 * | Vector2Subtract (Vector2 *result, const Vector2 *leftSide, const Vector2 *rightSide) |
Vector3 * | Vector3Subtract (Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide) |
Vector4 * | Vector4Subtract (Vector4 *result, const Vector4 *leftSide, const Vector4 *rightSide) |
Vector2 * | Vector2Scale (Vector2 *result, const Vector2 *input, const float scalar) |
Vector3 * | Vector3Scale (Vector3 *result, const Vector3 *input, const float scalar) |
Vector4 * | Vector4Scale (Vector4 *result, const Vector4 *input, const float scalar) |
Vector2 * | Vector2ScaleDivide (Vector2 *result, const Vector2 *input, const float scalar) |
Vector3 * | Vector3ScaleDivide (Vector3 *result, const Vector3 *input, const float scalar) |
Vector4 * | Vector4ScaleDivide (Vector4 *result, const Vector4 *input, const float scalar) |
Vector2 * | Vector2Negate (Vector2 *result, const Vector2 *input) |
Vector3 * | Vector3Negate (Vector3 *result, const Vector3 *input) |
Vector4 * | Vector4Negate (Vector4 *result, const Vector4 *input) |
float | Vector2DotProduct (const Vector2 *leftSide, const Vector2 *rightSide) |
float | Vector3DotProduct (const Vector3 *leftSide, const Vector3 *rightSide) |
float | Vector4DotProduct (const Vector4 *leftSide, const Vector4 *rightSide) |
Vector3 * | Vector3CrossProduct (Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide) |
float | Vector2Magnitude (const Vector2 *input) |
float | Vector3Magnitude (const Vector3 *input) |
float | Vector4Magnitude (const Vector4 *input) |
float | Vector2MagnitudeSquared (const Vector2 *input) |
float | Vector3MagnitudeSquared (const Vector3 *input) |
float | Vector4MagnitudeSquared (const Vector4 *input) |
Vector2 * | Vector2Normalize (Vector2 *result, const Vector2 *input) |
Vector3 * | Vector3Normalize (Vector3 *result, const Vector3 *input) |
Vector4 * | Vector4Normalize (Vector4 *result, const Vector4 *input) |
Vector2 * | Vector2NormalizeMagnitude (Vector2 *result, const Vector2 *input, float &magnitude) |
Vector3 * | Vector3NormalizeMagnitude (Vector3 *result, const Vector3 *input, float &magnitude) |
Vector4 * | Vector4NormalizeMagnitude (Vector4 *result, const Vector4 *input, float &magnitude) |
Angle | Vector3AngleBetween (const Vector3 *left, const Vector3 *right) |
static Vector3 & | RotationXZToForwardVector3 (Vector3 &result, const Angle &orientation) |
static Vector2 & | RotationToForwardVector2 (Vector2 &result, const Angle &orientation) |
static Angle | ForwardVector3ToRotationXZ (const Vector3 &forward) |
static Angle | ForwardVector2ToRotation (const Vector2 &forward) |
Variables | |
static const float | kPi = Pi<float>() |
A constant for the mathematical concept of Pi stored in a float. | |
static const float | kTwoPi = TwoPi<float>() |
A constant for Pi * 2 stored in a float. | |
Also known as tbMath, the objects and functions within the namespace TurtleBrains::Math are aimed to help reduce the burden with math by providing 2, 3 and 4 component Vector, 4x4 Matrix for transforms and a variety of helper functions for general purpose, converting values or interpolating.
typedef AngleType<float> TurtleBrains::Math::Angle |
Specialization of the most common use of Angle, as a float.
|
strong |
Used to specify whether an AngleType object is in Degrees or Radians when constructing.
Enumerator | |
---|---|
Degrees |
Specifies the angle input value is in units of Degrees. |
Radians |
Specifies the angle input value is in units of Radians. |
The SkipInitialization type is used to provide a non-constructor to a few objects, essentially Vector2, Vector3, Vector4 objects. The non-constructor essentially leaves the members of the object uninitialized. This is unsafe but allows for slightly faster creation of the object with the premise that the values will be set immediately after.
Provides constant values for each component of the Vector2, Vector3 and Vector4 objects to get the component values by index using operator[].
Enumerator | |
---|---|
kComponentX |
The index of the x component of the Vector2, Vector3 and Vector4 objects. |
kComponentY |
The index of the y component of the Vector2, Vector3 and Vector4 objects. |
kComponentZ |
The index of the z component of the Vector3, Vector4 objects. |
kComponentW |
The index of the w component of the Vector4 object. |
|
noexcept |
Returns a value that falls within the given range of minimumValue to maximumValue using only the less-than operator for the type.
value | The value that will be returned if it is within the range provided. |
minimumValue | The lower end of the range to clamp the value at, will be returned if the value is less-than the range. |
maximumValue | The upper end of the range to clamp the value at, will be returned if the value is greater-than the range. |
Converts a normalized 'forward' vector to an orientation value for 2D games. The orientation returned will be the radians in a clockwise (in normal 2D TurtleBrains with +X being to screen right, and +Y being to screen down) from the negative Y-Axis, meaning that something pointing up the screen (-Y) will return 0.
forward | should be a normalized vector. |
Converts a normalized 'forward' vector to an orientation value for 2D games. The orientation returned will be an Angle object clockwise (TODO: TIM: Double check this directional comment) from the ZAxis, meaning the input vector should be something like forwardX, 0, forwardZ instead of the forwardX, forwardY.
forward | should be a vector on the XZ plane. |
bool TurtleBrains::Math::IsEqual | ( | const Type & | leftValue, |
const Type & | rightValue | ||
) |
Compares two floating point values returning true if the difference between the two values is less-than or equal to the tolerance allowed.
leftValue | The value that would be on the left side of the comparison operator. |
rightValue | The value that would be on the right side of the comparison operator. |
tolerance | An optional value to change the tolerance of the comparison, smaller value means the floats need to be closer together, defaults to kTolerance. |
bool TurtleBrains::Math::IsZero | ( | const Type & | value | ) |
Compares a floating point values returning true if the difference between the value and zero is less-than or equal to the tolerance allowed.
value | The value to check if it is within the tolerance range of zero. |
tolerance | An optional value to change the tolerance of the comparison, smaller value means the floats need to be closer together, defaults to kTolerance. |
|
static |
When comparing a float for equality or to zero, this is the default tolerance used. When the difference is less than the tolerance, the values are considered the same.
|
inline |
Computes the determinant of the 3x3 matrix components and returns the result. Essentially a supporting function for MatrixDeterminant and ComputeInverse below for the 4x4 matrix.
|
inline |
Adds two Matrix objects together into matrixResult and then the results matrix is returned.
result | The matrix to fill out and return with the result of the two matrices added together. |
leftSide | The matrix on the left side of the addition operator. |
rightSide | The matrix on the right side of the addition operator. |
|
inline |
Adds two Matrix objects together into matrixResult and then the results matrix is returned.
result | The matrix to fill out and return with the result of the two matrices added together. |
leftSide | The matrix on the left side of the addition operator. |
rightSide | The matrix on the right side of the addition operator. |
|
inline |
TODO: TurtleBrains: Math: This is not documented or implemented or tested... (Why does it exist at all?)
|
inline |
Computes the inverse matrix that when multiplied against the initial input would result in an identity matrix.
result | The matrix to store and return the computed inverse matrix of input. This cannot be the same matrix as the input matrix or an error condition will be triggered. |
input | The matrix to compute the inverse of, cannot be the same as the result matrix or an error condition will be triggered. |
------------------------------------------------------------------------------------------------------------——/// ------------------------------------------------------------------------------------------------------------——/// ------------------------------------------------------------------------------------------------------------——///
Fills the matrix with the values from the identity matrix and returns the result.
result | The matrix to fill out and return. |
|
inline |
Creates a transform Matrix from a forward vector and up vector, similar to creating a LookAt.
result | The matrix to fill out with the resulting LookAt matrix. |
forward | The direction the transform matrix will be pointing at, must be a unit vector of the direction. |
up | A unit vector representing the up vector, this is expected to be normalized / length of 1.0. |
|
inline |
Creates a right-handed orthographic matrix for 2D rendering given a few setup parameters. The Matrix will look something like the following once returned:
2 / (r - l), 0, 0, -(r + l) / (r - l), 0, 2 / (t - b), 0, -(t + b) / (t - b), 0, 0, 2 / (f - n), -(f + n) / (f - n), 0, 0, 0 1
result | Where to store the resulting matrix and return. |
width | The width of the screen/window/surface available for the 2D rendering. |
height | The height of the screen/window/surface available for the 2D rendering. |
nearPlane | The distance to the near plane of the orthographic matrix. (closest Z value). |
farPlane | The distance to the far plane of the orthographic matrix. (farthest Z value). |
|
inline |
Creates a right-handed orthographic matrix for 2D rendering given a few setup parameters. The Matrix will look something like the following once returned:
2 / (r - l), 0, 0, -(r + l) / (r - l), 0, 2 / (t - b), 0, -(t + b) / (t - b), 0, 0, -2 / (f - n), -(f + n) / (f - n), 0, 0, 0 1
result | Where to store the resulting matrix and return. |
width | The width of the screen/window/surface available for the 2D rendering. |
height | The height of the screen/window/surface available for the 2D rendering. |
nearPlane | The distance to the near plane of the orthographic matrix. (closest Z value). |
farPlane | The distance to the far plane of the orthographic matrix. (farthest Z value). |
|
inline |
Creates a left-handed projection matrix for 3D rendering given a few setup parameters.
result | Where to store the resulting matrix and return. |
fieldOfView | The angle (in radians) of the vertical field of vision for the projection matrix. To use horizontal field of view, just use verticalFOV / aspectRatio when calling. |
aspectRatio | The aspect ratio of the window/screen or target render. |
nearPlane | The distance to the near plane of the projection matrix. |
farPlane | The distance to the far plane of the projection matrix. |
|
inline |
Creates a right-handed projection matrix for 3D rendering given a few setup parameters.
result | Where to store the resulting matrix and return. |
fieldOfView | The angle (in radians) of the vertical field of vision for the projection matrix. To use horizontal field of view, just use verticalFOV / aspectRatio when calling. |
aspectRatio | The aspect ratio of the window/screen or target render. |
nearPlane | The distance to the near plane of the projection matrix. |
farPlane | The distance to the far plane of the projection matrix. |
|
inline |
Creates a rotation transform Matrix object with no translation or scaling that will rotate around the specied rotationAxis by the amount specified by the rotation parameter.
result | The matrix to hold the result and be returned. |
rotationAxis | The axis to rotate around, should be a unit vector, can be an arbitrary direction. |
rotationInDegrees | The amount to rotate around the Z-axis in degrees. |
|
inline |
Creates a rotation transform Matrix object with no translation or scaling that will rotate around the specied rotationAxis by the amount specified by the rotation parameter.
result | The matrix to hold the result and be returned. |
rotationAxis | The axis to rotate around, should be a unit vector, can be an arbitrary direction. |
rotationInDegrees | The amount to rotate around the Z-axis in degrees. |
|
inline |
Creates a rotation transform Matrix object with no translation or scaling that will rotate around the X-axis by the amount specified by the rotation parameter.
result | The matrix to hold the result and be returned. |
rotationInDegrees | The amount to rotate around the X-axis in degrees. |
|
inline |
Creates a rotation transform Matrix object with no translation or scaling that will rotate around the X-axis by the amount specified by the rotation parameter.
result | The matrix to hold the result and be returned. |
rotationInDegrees | The amount to rotate around the X-axis in degrees. |
|
inline |
Creates a rotation transform Matrix object with no translation or scaling that will rotate around the Y axis by the amount specified by the rotation parameter.
result | The matrix to hold the result and be returned. |
rotationInDegrees | The amount to rotate around the Y-axis in degrees. |
|
inline |
Creates a rotation transform Matrix object with no translation or scaling that will rotate around the Y axis by the amount specified by the rotation parameter.
result | The matrix to hold the result and be returned. |
rotationInDegrees | The amount to rotate around the Y-axis in degrees. |
|
inline |
Creates a rotation transform Matrix object with no translation or scaling that will rotate around the X-axis by the amount specified by the rotation parameter.
result | The matrix to hold the result and be returned. |
rotationInDegrees | The amount to rotate around the Z-axis in degrees. |
|
inline |
Creates a rotation transform Matrix object with no translation or scaling that will rotate around the X-axis by the amount specified by the rotation parameter.
result | The matrix to hold the result and be returned. |
rotationInDegrees | The amount to rotate around the Z-axis in degrees. |
Creates a scale transform Matrix object with no translation or rotation set to the position specified by the Vector object.
result | The matrix to hold the result and be returned. |
scale | The amount of scaling of each axis represented by the vector components. |
|
inline |
Creates a scale transform Matrix object with no translation or rotation set to the position specified by the x, y, z parameter values.
result | The matrix to hold the result and be returned. |
scaleX | The amount of scaling for the transform matrix in the X-axis. |
scaleY | The amount of scaling for the transform matrix in the Y-axis. |
scaleZ | The amount of scaling for the transform matrix in the Z-axis. |
|
inline |
|
inline |
Creates a translation transform Matrix object with no rotation set to the position specified by the Vector.
result | The matrix to hold the result and be returned. |
translation | The amount of translation to add in each axis represented by the vector components. |
|
inline |
Creates a translation transform Matrix object with no rotation set to the position specified by the x, y, z parameter values.
result | The matrix to hold the result and be returned. |
translationX | The amount of translation to add to the transform matrix in the X-axis. |
translationY | The amount of translation to add to the transform matrix in the Y-axis. |
translationZ | The amount of translation to add to the transform matrix in the Z-axis. |
|
inline |
Computes the determinant of the 3x3 matrix by breaking it down into 2x2 determinants and returns the resulting scalar determinant.
|
inline |
Computes the determinant of the 4x4 matrix by breaking it down into 3x3 determinants and returns the resulting scalar determinant.
Creates the inverse matrix for a special, ortho-normalized matrix by transposing the 3x3.
result | The matrix to store and return the computed inverse matrix of input. This cannot be the same matrix as the input matrix or an error condition will be triggered. |
input | The matrix to compute the inverse of, cannot be the same as the result matrix or an error condition will be triggered. |
Creates the inverse matrix for a special, ortho-normalized matrix by transposing the 3x3 in the top-left, negating the translation and multiplying it by that new 3x3 and keeping the diagonal equal.
A = [ M b ] [ 0 1 ] where, M is 3x3, b is 1x3, and bottom is 0, 0, 0, 1 inv(A) = [ inv(M) -inv(M) * b ] [ 0 1 ]
result | The matrix to store and return the computed inverse matrix of input. This cannot be the same matrix as the input matrix or an error condition will be triggered. |
input | The matrix to compute the inverse of, cannot be the same as the result matrix or an error condition will be triggered. |
|
inline |
Multiplies two matrices together and stores the resulting matrix to be returned.
result | The result matrix which will be the product of leftSide * rightSide when finished. This matrix cannot be the same as leftSide or rightSide or an error condition will be triggered. |
leftSide | The matrix on the left side of the multiplication operation. This cannot be the same as the result matrix or an error condition will be triggered. |
rightSide | The matrix on the right side of the multiplication operation. This cannot be the same as the result matrix or an error condition will be trtiggered. |
|
inline |
|
inline |
Scales/multiplies each component of the matrix by the given scalar value.
result | The result matrix which will be the product of input * scalar when finished. |
input | The original matrix that should be scaled / multiplied with the scalar. |
scalar | How much to multiply each component of the matrix by. |
TODO: TurtleBrains: Math: This will need some simple unit testing, though really it is easy enough.
|
inline |
Scales/multiplies each component of the matrix by the given scalar value.
result | The result matrix which will be the product of input * scalar when finished. |
input | The original matrix that should be scaled / multiplied with the scalar. |
scalar | How much to multiply each component of the matrix by. |
TODO: TurtleBrains: Math: This will need some simple unit testing, though really it is easy enough.
|
inline |
Subtracts rightSide matrix from the leftSide matrix and stores the result into result before returning.
result | The matrix to fill out and return with the result of: leftSide - rightSide. |
leftSide | The matrix on the left side of the subtration operator. |
rightSide | The matrix on the right side of the subtraction operator. |
|
inline |
Subtracts rightSide matrix from the leftSide matrix and stores the result into result before returning.
result | The matrix to fill out and return with the result of: leftSide - rightSide. |
leftSide | The matrix on the left side of the subtration operator. |
rightSide | The matrix on the right side of the subtraction operator. |
Fills the compoments of result Matrix3 object so it would be the transposed of the input Matrix.
result | The resulting matrix of the transposed operation on input, cannot be the same as the input matrix. |
input | The matrix to get the transposed result of, cannot be the same as the result matrix. |
Fills the compoments of result Matrix4 object so it would be the transposed of the input Matrix.
result | The resulting matrix of the transposed operation on input, cannot be the same as the input matrix. |
input | The matrix to get the transposed result of, cannot be the same as the result matrix. |
|
inline |
Multiplies a matrix and a vector together treating the vector as a 3(row) 1(column) matrix.
result | The vector to hold the result of the transformed inputVector), must be a different vector object or an error condition will be triggered. |
inputVector | The vector to transform by the input matrix, must not be the same as result. |
inputMatrix | The transform matrix to multiply inputVector by. |
|
inline |
Multiplies a matrix and a vector together treating the vector as a 4(row) 1(column) matrix.
result | The vector to hold the result of the transformed inputVector), must be a different vector object or an error condition will be triggered. |
inputVector | The vector to transform by the input matrix), must not be the same as result. |
inputMatrix | The transform matrix to multiply inputVector by. |
|
noexcept |
Compares the value of two similar types using the less-than operator returning the greater of the values.
leftValue | The value that would be on the left side of the comparison operator. |
rightValue | The value that would be on the right side of the comparison operator. |
|
noexcept |
Compares the value of two similar types using the less-than operator returning the lesser of the values.
leftValue | The value that would be on the left side of the comparison operator. |
rightValue | The value that would be on the right side of the comparison operator. |
float TurtleBrains::Math::RandomFloat | ( | void | ) |
Create a random float in the range of: 0.0f <= value <= 1.0f
float TurtleBrains::Math::RandomFloat | ( | const float | minimumValue, |
const float | maximumValue | ||
) |
Returns a random float value between minimumValue and maximumValue inclusively.
minimumValue | The smallest possible random value desired, must be less than maximumValue. |
maximumValue | The largest possible random value desired, must be greater than minimumValue. |
int TurtleBrains::Math::RandomInt | ( | void | ) |
Returns a random integer between 0 and RAND_MAX by returning rand(), a better random-number generator may be used in future versions of TurtleBrains.
int TurtleBrains::Math::RandomInt | ( | const int | minimumValue, |
const int | maximumValue | ||
) |
Returns a random integer between minimumValue and maximumValue inclusively.
minimumValue | The smallest possible random value desired, must be less than maximumValue. |
maximumValue | The largest possible random value desired, must be greater than minimumValue. |
|
inlinestatic |
Converts an orientation value from 2D into a forward vector. Orientation should be in radians, positive for clockwise rotation around the Z axis, 0 pointing along the -Y axis.
|
inlinestatic |
Converts an orientation value from 2D (XZ plane) into a forward vector X, 0, Z. Orientation should be in radians, positive for clockwise rotation around the Y axis, 0 pointing along the -Z axis.
unsigned int TurtleBrains::Math::SeedRandomGenerator | ( | void | ) |
Generates a seed using time() and seeds the random generator, returning the seed used.
unsigned int TurtleBrains::Math::SeedRandomGenerator | ( | const tbCore::tbString & | seed | ) |
Generates a seed using the hash of the string passed as parameter seed, then proceeds seed the the random generator, finally return the value as an unsigned int.
seed | A string, usually shortish, to hash into an unsigned int which will be the generated seed. |
void TurtleBrains::Math::SeedRandomGenerator | ( | unsigned int | seed | ) |
Starts the random generator with a specific seed.
|
inline |
Add two the components of one Vector to another Vector and return the resulting Vector. Behavior is the same as Vector::operator+
result | is the result of leftSide + rightSide. |
leftSide | The Vector object to take the left hand side of the addition operation. |
rightSide | The Vector object to take the right hand side of the addition operation. |
|
inline |
Performs the DotProduct on two Vector objects returning resulting scalar value.
leftSide | The Vector object to take the left hand side of the dot product operation. |
rightSide | The Vector object to take the right hand side of the dot product operation. |
|
inline |
Computes the length (magnitude) of a Vector object returning resulting scalar value.
input | The Vector object to compute the length of. |
|
inline |
Computes the length (magnitude) of a Vector object without performing the square-root, so the resulting scalar is actually the squared length of the Vector.
input | The Vector object to get the squared length of. |
Negates each of the components of a Vector and returns the resulting Vector.
result | The result of negating each component in input. |
input | The Vector object to negate. |
Calculates the unit-length vector of the input Vector and returns the resulting Vector.
result | The unit length vector from the input, or a zero vector if the input had no length. |
input | The Vector object to get the unit-length of. |
|
inline |
Calculates the unit-length vector of the input Vector and returns the resulting Vector and to save computing the magnitude elsewhere, this will return the value in the magnitude parameter.
result | The unit length vector from the input, or a zero vector if the input had no length. |
input | The Vector object to get the unit-length of. |
magnitude | The length of the input vector as it must be computed. |
|
inline |
Scales the components of one Vector and returns the resulting Vector.
result | The result of input * scalar. |
input | The Vector object to scale by the scalar value. |
scalar | The amount to scale the input Vector by. 2.0f would double the Vectors magnitude. |
|
inline |
Divides the components of one Vector by the scalar and returns the resulting Vector.
result | The result of input * scalar. |
input | The Vector object to scale by the scalar value. |
scalar | The amount to inverse scale the input Vector by. 2.0f would half the Vectors magnitude. |
|
inline |
Subtracts the components of one Vector from another Vector and returns the resulting Vector. Behavior is the same as using Vector::operator-
result | is the result of leftSide - rightSide. |
leftSide | The Vector object to take the left hand side of the subtraction operation. |
rightSide | The Vector object to take the right hand side of the subtraction operation. |
|
inline |
Add two the components of one Vector to another Vector and return the resulting Vector. Behavior is the same as Vector::operator+
result | is the result of leftSide + rightSide. |
leftSide | The Vector object to take the left hand side of the addition operation. |
rightSide | The Vector object to take the right hand side of the addition operation. |
|
inline |
Returns angle between vectors in radians, 0 is both pointing same direction, kPi if both vectors are pointing in opposite directions.
|
inline |
Computes the CrossProduct of two Vector objects. The resulting Vector will be perpendicular to the input vectors, or become a zero vector if those are parallel. Assuming a right hand coordinate system, X cross Y will result in Z while Y cross X would be -Z. An easy way to get the axis you want is to write xyzxyz, then find the axis you want (ex: Want Y, Y = Z cross X). Again this works for a right handed system because x cross y will be a positive z.
result | The result of leftSide cross rightSide, also performed with operator^ |
leftSide | The Vector object to take the left hand side of the cross product operation. |
rightSide | The Vector object to take the right hand side of the cross product operation. |
|
inline |
Performs the DotProduct on two Vector objects returning resulting scalar value.
leftSide | The Vector object to take the left hand side of the dot product operation. |
rightSide | The Vector object to take the right hand side of the dot product operation. |
|
inline |
Computes the length (magnitude) of a Vector object returning resulting scalar value.
input | The Vector object to compute the length of. |
|
inline |
Computes the length (magnitude) of a Vector object without performing the square-root, so the resulting scalar is actually the squared length of the Vector.
input | The Vector object to get the squared length of. |
|
inline |
Multiplies a vector and a matrix together treating the vector as a 3(row) 1(column) matrix.
result | The vector to hold the result of the transformed inputVector), must be a different vector object or an error condition will be triggered. |
inputVector | The vector to transform by the input matrix), must not be the same as result. |
inputMatrix | The transform matrix to multiply inputVector by. |
Negates each of the components of a Vector and returns the resulting Vector.
result | The result of negating each component in input. |
input | The Vector object to negate. |
Calculates the unit-length vector of the input Vector and returns the resulting Vector.
result | The unit length vector from the input, or a zero vector if the input had no length. |
input | The Vector object to get the unit-length of. |
|
inline |
Calculates the unit-length vector of the input Vector and returns the resulting Vector and to save computing the magnitude elsewhere, this will return the value in the magnitude parameter.
result | The unit length vector from the input, or a zero vector if the input had no length. |
input | The Vector object to get the unit-length of. |
magnitude | The length of the input vector as it must be computed. |
|
inline |
Scales the components of one Vector and returns the resulting Vector.
result | The result of input * scalar. |
input | The Vector object to scale by the scalar value. |
scalar | The amount to scale the input Vector by. 2.0f would double the Vectors magnitude. |
|
inline |
Divides the components of one Vector by the scalar and returns the resulting Vector.
result | The result of input * scalar. |
input | The Vector object to scale by the scalar value. |
scalar | The amount to inverse scale the input Vector by. 2.0f would half the Vectors magnitude. |
|
inline |
Subtracts the components of one Vector from another Vector and returns the resulting Vector. Behavior is the same as using Vector::operator-
result | is the result of leftSide - rightSide. |
leftSide | The Vector object to take the left hand side of the subtraction operation. |
rightSide | The Vector object to take the right hand side of the subtraction operation. |
|
inline |
Multiplies a vector and matrix together to transform the inputVector into the space described by the inputMatrix storing and returning the result. This behaves identical to Vector4MatrixMultiply except with Vector3, 1.0f and it can reduce that final round of multiplications.
result | The vector to hold the result of the transformed inputVector, must be a different vector object or an error condition will be triggered. |
inputVector | The vector to transform by the input matrix, must not be the same as result. |
inputMatrix | The transform matrix to multiply inputVector by. |
|
inline |
Multiplies a vector and matrix together to transform the inputVector into the space described by the inputMatrix storing and returning the result. This behaves identical to Vector4MatrixMultiply except with Vector3, 0.0f and it can reduces that final round of adding and the multiplications. It differs from TransformCoordinate by not applying the translation, useful for directions/normals.
result | The vector to hold the result of the transformed inputVector, must be a different vector object or an error condition will be triggered. |
inputVector | The vector to transform by the input matrix, must not be the same as result. |
inputMatrix | The transform matrix to multiply inputVector by. |
|
inline |
Add two the components of one Vector to another Vector and return the resulting Vector. Behavior is the same as Vector::operator+
result | is the result of leftSide + rightSide. |
leftSide | The Vector object to take the left hand side of the addition operation. |
rightSide | The Vector object to take the right hand side of the addition operation. |
|
inline |
Performs the DotProduct on two Vector objects returning resulting scalar value.
leftSide | The Vector object to take the left hand side of the dot product operation. |
rightSide | The Vector object to take the right hand side of the dot product operation. |
|
inline |
Computes the length (magnitude) of a Vector object returning resulting scalar value.
input | The Vector object to compute the length of. |
|
inline |
Computes the length (magnitude) of a Vector object without performing the square-root, so the resulting scalar is actually the squared length of the Vector.
input | The Vector object to get the squared length of. |
|
inline |
Multiplies a vector and a matrix together treating the vector as a 4(row) 1(column) matrix.
result | The vector to hold the result of the transformed inputVector), must be a different vector object or an error condition will be triggered. |
inputVector | The vector to transform by the input matrix), must not be the same as result. |
inputMatrix | The transform matrix to multiply inputVector by. |
Negates each of the components of a Vector and returns the resulting Vector.
result | The result of negating each component in input. |
input | The Vector object to negate. |
Calculates the unit-length vector of the input Vector and returns the resulting Vector.
result | The unit length vector from the input, or a zero vector if the input had no length. |
input | The Vector object to get the unit-length of. |
|
inline |
Calculates the unit-length vector of the input Vector and returns the resulting Vector and to save computing the magnitude elsewhere, this will return the value in the magnitude parameter.
result | The unit length vector from the input, or a zero vector if the input had no length. |
input | The Vector object to get the unit-length of. |
magnitude | The length of the input vector as it must be computed. |
|
inline |
Scales the components of one Vector and returns the resulting Vector.
result | The result of input * scalar. |
input | The Vector object to scale by the scalar value. |
scalar | The amount to scale the input Vector by. 2.0f would double the Vectors magnitude. |
|
inline |
Divides the components of one Vector by the scalar and returns the resulting Vector.
result | The result of input * scalar. |
input | The Vector object to scale by the scalar value. |
scalar | The amount to inverse scale the input Vector by. 2.0f would half the Vectors magnitude. |
|
inline |
Subtracts the components of one Vector from another Vector and returns the resulting Vector. Behavior is the same as using Vector::operator-
result | is the result of leftSide - rightSide. |
leftSide | The Vector object to take the left hand side of the subtraction operation. |
rightSide | The Vector object to take the right hand side of the subtraction operation. |