TurtleBrains  0.2.1
High quality, portable, C++ API for native application and game development.
TurtleBrains::Math Namespace Reference

Contains objects and functions for dealing with Vector and Matrix math. More...

Classes

class  Matrix3
 
class  Matrix4
 
class  Vector2
 
class  Vector3
 
class  Vector4
 

Enumerations

enum  SkipInitialization { kSkipInitialization = 0 }
 
enum  VectorComponent { kComponentX = 0, kComponentY, kComponentZ, kComponentW }
 

Functions

static const float kPi (3.141592f)
 A constant for the mathematical concept of Pi stored in a float.
 
static const float kTwoPi (kPi *2.0f)
 A constant for Pi * 2 stored in a float.
 
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.
 
bool IsEqual (const float leftValue, const float rightValue, const float tolerance=tbMath::kTolerance)
 
bool IsZero (const float value, const float tolerance=tbMath::kTolerance)
 
template<typename T >
const T & Maximum (const T &leftValue, const T &rightValue)
 
template<typename T >
const T & Minimum (const T &leftValue, const T &rightValue)
 
template<typename T >
const T & Clamp (const T &value, const T &minimumValue, const T &maximumValue)
 
Matrix4MatrixCreateIdentity (Matrix4 *result)
 
Matrix4MatrixCreateFromForward (Matrix4 *result, const Vector3 *forward, const Vector3 *up=NULL)
 
Matrix4MatrixCreateTranslation (Matrix4 *result, const Vector3 *translation)
 
Matrix4MatrixCreateTranslation (Matrix4 *result, const float translationX, const float translationY, const float translationZ)
 
Matrix4MatrixCreateScale (Matrix4 *result, Vector3 *scale)
 
Matrix4MatrixCreateScale (Matrix4 *result, const float scaleX, const float scaleY, const float scaleZ)
 
Matrix4MatrixCreateRotationX (Matrix4 *result, const float rotationInDegrees)
 
Matrix4MatrixCreateRotationY (Matrix4 *result, const float rotationInDegrees)
 
Matrix4MatrixCreateRotationZ (Matrix4 *result, const float rotationInDegrees)
 
Matrix4MatrixCreateRotationA (Matrix4 *result, const Vector3 *rotationAxis, const float rotationInDegrees)
 
Matrix4MatrixCreatePerspectiveRH (Matrix4 *result, const float fieldOfView, const float aspectRatio, const float nearPlane, const float farPlane)
 
Matrix4MatrixCreatePerspectiveLH (Matrix4 *result, const float fieldOfView, const float aspectRatio, const float nearPlane, const float farPlane)
 
Matrix4MatrixCreateOrthoRH (Matrix4 *result, const float width, const float height, const float nearPlane, const float farPlane)
 
Matrix4MatrixCreateOrthoLH (Matrix4 *result, const float width, const float height, const float nearPlane, const float farPlane)
 
Matrix4MatrixAdd (Matrix4 *result, const Matrix4 *leftSide, const Matrix4 *rightSide)
 
Matrix4MatrixSubtract (Matrix4 *result, const Matrix4 *leftSide, const Matrix4 *rightSide)
 
Matrix4MatrixTranspose (Matrix4 *result, const Matrix4 *input)
 
Matrix4MatrixMultiply (Matrix4 *result, const Matrix4 *leftSide, const Matrix4 *rightSide)
 
Vector4Vector4MatrixMultiply (Vector4 *result, const Vector4 *inputVector, const Matrix4 *inputMatrix)
 
Vector3Vector3TransformCoord (Vector3 *result, const Vector3 *inputVector, const Matrix4 *inputMatrix)
 
Vector3Vector3TransformNormal (Vector3 *result, const Vector3 *inputVector, const Matrix4 *inputMatrix)
 
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 Matrix4 *input)
 
Matrix4MatrixComputeInverse (Matrix4 *result, const Matrix4 *input)
 
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)
 
Vector2Vector2Add (Vector2 *result, const Vector2 *leftSide, const Vector2 *rightSide)
 
Vector3Vector3Add (Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide)
 
Vector4Vector4Add (Vector4 *result, const Vector4 *leftSide, const Vector4 *rightSide)
 
Vector2Vector2Subtract (Vector2 *result, const Vector2 *leftSide, const Vector2 *rightSide)
 
Vector3Vector3Subtract (Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide)
 
Vector4Vector4Subtract (Vector4 *result, const Vector4 *leftSide, const Vector4 *rightSide)
 
Vector2Vector2Scale (Vector2 *result, const Vector2 *input, const float scalar)
 
Vector3Vector3Scale (Vector3 *result, const Vector3 *input, const float scalar)
 
Vector4Vector4Scale (Vector4 *result, const Vector4 *input, const float scalar)
 
Vector2Vector2ScaleDivide (Vector2 *result, const Vector2 *input, const float scalar)
 
Vector3Vector3ScaleDivide (Vector3 *result, const Vector3 *input, const float scalar)
 
Vector4Vector4ScaleDivide (Vector4 *result, const Vector4 *input, const float scalar)
 
Vector2Vector2Negate (Vector2 *result, const Vector2 *input)
 
Vector3Vector3Negate (Vector3 *result, const Vector3 *input)
 
Vector4Vector4Negate (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)
 
Vector3Vector3CrossProduct (Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide)
 
Vector4Vector4CrossProduct (Vector4 *result, const Vector4 *leftSide, const Vector4 *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)
 
Vector2Vector2Normalize (Vector2 *result, const Vector2 *input)
 
Vector3Vector3Normalize (Vector3 *result, const Vector3 *input)
 
Vector4Vector4Normalize (Vector4 *result, const Vector4 *input)
 
Vector2Vector2NormalizeMagnitude (Vector2 *result, const Vector2 *input, float &magnitude)
 
Vector3Vector3NormalizeMagnitude (Vector3 *result, const Vector3 *input, float &magnitude)
 
Vector4Vector4NormalizeMag (Vector4 *result, const Vector4 *input, float &magnitude)
 
float Vector3AngleBetween (const Vector3 *left, const Vector3 *right)
 
static Vector3OrientationToForwardVector3 (Vector3 *result, float orientation)
 
static Vector2OrientationToForwardVector2 (Vector2 &result, float orientation)
 
static float ForwardVector3ToOrientation (const Vector3 &forward)
 
static float ForwardVector2ToOrientation (const Vector2 &forward)
 

Detailed Description

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.

Enumeration Type Documentation

The SkipInitialization type is used to provide a non-constuctor 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.

Note
Should be used only if the consequences are understood, and even then only sparingly.

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.

Function Documentation

template<typename T >
const T& TurtleBrains::Math::Clamp ( const T &  value,
const T &  minimumValue,
const T &  maximumValue 
)

Returns a value that falls within the given range of minimumValue to maximumValue using only the less-than operator for the type.

Parameters
valueThe value that will be returned if it is within the range provided.
minimumValueThe lower end of the range to clamp the value at, will be returned if the value is less-than the range.
maximumValueThe upper end of the range to clamp the value at, will be returned if the value is greater-than the range.
Note
There will be compile issues if called on a type that does not have an operator< to use.
static float TurtleBrains::Math::ForwardVector2ToOrientation ( const Vector2 forward)
inlinestatic

Converts a normalized 'forward' vector to an orientation value for 2D games. The orientation returned will be the radians in a clockwise (TODO: TIM: Doublecheck this directional comment) from the negative Y-Axis, meaning that something pointing up the screen (-Y) will return 0.

Parameters
forwardshould be a normalized vector.
Note
the orientation is in radians, not degrees.
static float TurtleBrains::Math::ForwardVector3ToOrientation ( const Vector3 forward)
inlinestatic

Converts a normalized 'forward' vector to an orientation value for 2D games. The orientation returned will be the radians in a clockwise (TODO: TIM: Doublecheck this directional comment) from the ZAxis, meaning the input vector should be something like forwardX, 0, forwardZ instead of the forwardX, forwardY.

Parameters
forwardshould be a vector on the XZ plane.
Note
the orientation is in radians, not degrees.
bool TurtleBrains::Math::IsEqual ( const float  leftValue,
const float  rightValue,
const float  tolerance = tbMath::kTolerance 
)
inline

Compares two floating point values returning true if the difference between the two values is less-than or equal to the tolerance allowed.

Parameters
leftValueThe value that would be on the left side of the comparison operator.
rightValueThe value that would be on the right side of the comparison operator.
toleranceAn 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 float  value,
const float  tolerance = tbMath::kTolerance 
)
inline

Compares a floating point values returning true if the difference between the value and zero is less-than or equal to the tolerance allowed.

Parameters
valueThe value to check if it is within the tolerance range of zero.
toleranceAn optional value to change the tolerance of the comparison, smaller value means the floats need to be closer together, defaults to kTolerance.
static const float TurtleBrains::Math::kTolerance ( 0.  00001f)
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.

float TurtleBrains::Math::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 
)
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.

Matrix4* TurtleBrains::Math::MatrixAdd ( Matrix4 result,
const Matrix4 leftSide,
const Matrix4 rightSide 
)
inline

Adds two Matrix objects together into matrixResult and then the results matrix is returned.

Parameters
resultThe matrix to fill out and return with the result of the two matrices added together.
leftSideThe matrix on the left side of the addition operator.
rightSideThe matrix on the right side of the addition operator.
Matrix4* TurtleBrains::Math::MatrixComputeInverse ( Matrix4 result,
const Matrix4 input 
)
inline

Computes the inverse matrix that when multiplied against the initial input would result in an identity matrix.

Parameters
resultThe 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.
inputThe matrix to compute the inverse of, cannot be the same as the result matrix or an error condition will be triggered.
Note
this is a fairly heavy lifter so use lightly.
Matrix4* TurtleBrains::Math::MatrixCreateFromForward ( Matrix4 result,
const Vector3 forward,
const Vector3 up = NULL 
)
inline

Creates a transform Matrix from a forward vector and up vector, similar to creating a LookAt.

Parameters
resultThe matrix to fill out with the resulting LookAt matrix.
forwardThe direction the transform matrix will be pointing at, must be a unit vector of the direction.
upAn optional unit vector representing the up vector, if left NULL (0, 1, 0) will be used as a default up.
Note
Currently not yet implemented/tested so this will trigger an error condition if used.
Matrix4* TurtleBrains::Math::MatrixCreateIdentity ( Matrix4 result)
inline

------------------------------------------------------------------------------------------------------------——/// ------------------------------------------------------------------------------------------------------------——/// ------------------------------------------------------------------------------------------------------------——///

Fills the matrix with the values from the identity matrix and returns the result.

Parameters
resultThe matrix to fill out and return.
Matrix4* TurtleBrains::Math::MatrixCreateOrthoLH ( Matrix4 result,
const float  width,
const float  height,
const float  nearPlane,
const float  farPlane 
)
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 / width, 0, 0, 0, 0, 2 / height, 0, 0, 0, 0, 1 / (far-near), 0, 0, 0, near/(near-far) 1

Parameters
resultWhere to store the resulting matrix and return.
widthThe width of the screen/window/surface available for the 2D rendering.
heightThe height of the screen/window/surface available for the 2D rendering.
nearPlaneThe distance to the near plane of the orthographic matrix. (closest Z value).
farPlaneThe distance to the far plane of the orthographic matrix. (farthest Z value).
Matrix4* TurtleBrains::Math::MatrixCreateOrthoRH ( Matrix4 result,
const float  width,
const float  height,
const float  nearPlane,
const float  farPlane 
)
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 / width, 0, 0, 0, 0, 2 / height, 0, 0, 0, 0, 1 / (near-far), 0, 0, 0, near/(near-far) 1

Parameters
resultWhere to store the resulting matrix and return.
widthThe width of the screen/window/surface available for the 2D rendering.
heightThe height of the screen/window/surface available for the 2D rendering.
nearPlaneThe distance to the near plane of the orthographic matrix. (closest Z value).
farPlaneThe distance to the far plane of the orthographic matrix. (farthest Z value).
Matrix4* TurtleBrains::Math::MatrixCreatePerspectiveLH ( Matrix4 result,
const float  fieldOfView,
const float  aspectRatio,
const float  nearPlane,
const float  farPlane 
)
inline

Creates a left-handed projection matrix for 3D rendering given a few setup parameters.

Parameters
resultWhere to store the resulting matrix and return.
fieldOfViewThe vertical field of vision for the projection matrix.
aspectRatioThe aspect ratio of the window/screen or target render.
nearPlaneThe distance to the near plane of the projection matrix.
farPlaneThe distance to the far plane of the projection matrix.
Matrix4* TurtleBrains::Math::MatrixCreatePerspectiveRH ( Matrix4 result,
const float  fieldOfView,
const float  aspectRatio,
const float  nearPlane,
const float  farPlane 
)
inline

Creates a right-handed projection matrix for 3D rendering given a few setup parameters.

Parameters
resultWhere to store the resulting matrix and return.
fieldOfViewThe vertical field of vision for the projection matrix.
aspectRatioThe aspect ratio of the window/screen or target render.
nearPlaneThe distance to the near plane of the projection matrix.
farPlaneThe distance to the far plane of the projection matrix.
Matrix4* TurtleBrains::Math::MatrixCreateRotationA ( Matrix4 result,
const Vector3 rotationAxis,
const float  rotationInDegrees 
)
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.

Parameters
resultThe matrix to hold the result and be returned.
rotationAxisThe axis to rotate around, should be a unit vector, can be an arbitrary direction.
rotationInDegreesThe amount to rotate around the Z-axis in degrees.
Matrix4* TurtleBrains::Math::MatrixCreateRotationX ( Matrix4 result,
const float  rotationInDegrees 
)
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.

Parameters
resultThe matrix to hold the result and be returned.
rotationInDegreesThe amount to rotate around the X-axis in degrees.
Matrix4* TurtleBrains::Math::MatrixCreateRotationY ( Matrix4 result,
const float  rotationInDegrees 
)
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.

Parameters
resultThe matrix to hold the result and be returned.
rotationInDegreesThe amount to rotate around the Y-axis in degrees.
Matrix4* TurtleBrains::Math::MatrixCreateRotationZ ( Matrix4 result,
const float  rotationInDegrees 
)
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.

Parameters
resultThe matrix to hold the result and be returned.
rotationInDegreesThe amount to rotate around the Z-axis in degrees.
Matrix4* TurtleBrains::Math::MatrixCreateScale ( Matrix4 result,
Vector3 scale 
)
inline

Creates a scale transform Matrix object with no translation or rotation set to the position specified by the Vector object.

Parameters
resultThe matrix to hold the result and be returned.
scaleThe amount of scaling of each axis represented by the vector components.
Matrix4* TurtleBrains::Math::MatrixCreateScale ( Matrix4 result,
const float  scaleX,
const float  scaleY,
const float  scaleZ 
)
inline

Creates a scale transform Matrix object with no translation or rotation set to the position specified by the x, y, z parameter values.

Parameters
resultThe matrix to hold the result and be returned.
scaleXThe amount of scaling for the transform matrix in the X-axis.
scaleYThe amount of scaling for the transform matrix in the Y-axis.
scaleZThe amount of scaling for the transform matrix in the Z-axis.
Matrix4* TurtleBrains::Math::MatrixCreateTranslation ( Matrix4 result,
const Vector3 translation 
)
inline

Creates a translation transform Matrix object with no rotation set to the position specified by the Vector.

Parameters
resultThe matrix to hold the result and be returned.
translationThe amount of translation to add in each axis represented by the vector components.
Matrix4* TurtleBrains::Math::MatrixCreateTranslation ( Matrix4 result,
const float  translationX,
const float  translationY,
const float  translationZ 
)
inline

Creates a translation transform Matrix object with no rotation set to the position specified by the x, y, z parameter values.

Parameters
resultThe matrix to hold the result and be returned.
translationXThe amount of translation to add to the transform matrix in the X-axis.
translationYThe amount of translation to add to the transform matrix in the Y-axis.
translationZThe amount of translation to add to the transform matrix in the Z-axis.
float TurtleBrains::Math::MatrixDeterminant ( const Matrix4 input)
inline

Computes the determinant of the 4x4 matrix by breaking it down into 3x3 determinants and returns the resulting scalar determinant.

Matrix4* TurtleBrains::Math::MatrixMultiply ( Matrix4 result,
const Matrix4 leftSide,
const Matrix4 rightSide 
)
inline

Multiplies two matrices together and stores the resulting matrix to be returned.

Parameters
resultThe 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.
leftSideThe 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.
rightSideThe matrix on the right side of the multiplication operation. This cannot be the same as the result matrix or an error condition will be triggered.
Matrix4* TurtleBrains::Math::MatrixSubtract ( Matrix4 result,
const Matrix4 leftSide,
const Matrix4 rightSide 
)
inline

Subtracts rightSide matrix from the leftSide matrix and stores the result into result before returning.

Parameters
resultThe matrix to fill out and return with the result of: leftSide - rightSide.
leftSideThe matrix on the left side of the subtration operator.
rightSideThe matrix on the right side of the subtraction operator.
Matrix4* TurtleBrains::Math::MatrixTranspose ( Matrix4 result,
const Matrix4 input 
)
inline

Fills the compoments of result Matrix4 object so it would be the transposed of the input Matrix.

Parameters
resultThe resulting matrix of the transposed operation on input, cannot be the same as the input matrix.
inputThe matrix to get the transposed result of, cannot be the same as the result matrix.
template<typename T >
const T& TurtleBrains::Math::Maximum ( const T &  leftValue,
const T &  rightValue 
)

Compares the value of two similar types using the less-than operator returning the greater of the values.

Parameters
leftValueThe value that would be on the left side of the comparison operator.
rightValueThe value that would be on the right side of the comparison operator.
Note
There will be compile issues if called on a type that does not have an operator< to use.
template<typename T >
const T& TurtleBrains::Math::Minimum ( const T &  leftValue,
const T &  rightValue 
)

Compares the value of two similar types using the less-than operator returning the lesser of the values.

Parameters
leftValueThe value that would be on the left side of the comparison operator.
rightValueThe value that would be on the right side of the comparison operator.
Note
There will be compile issues if called on a type that does not have an operator< to use.
static Vector2& TurtleBrains::Math::OrientationToForwardVector2 ( Vector2 result,
float  orientation 
)
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.

static Vector3* TurtleBrains::Math::OrientationToForwardVector3 ( Vector3 result,
float  orientation 
)
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.

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.

Parameters
minimumValueThe smallest possible random value desired, must be less than maximumValue.
maximumValueThe largest possible random value desired, must be greater than minimumValue.
Note
This will trigger an error condition if minimumValue is not less than the maximumValue.
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.

Parameters
minimumValueThe smallest possible random value desired, must be less than maximumValue.
maximumValueThe largest possible random value desired, must be greater than minimumValue.
Note
This will trigger an error condition if minimumValue is not less than the maximumValue.
void TurtleBrains::Math::SeedRandomGenerator ( unsigned int  seed)

Starts the random generator with a specific seed.

Vector2* TurtleBrains::Math::Vector2Add ( Vector2 result,
const Vector2 leftSide,
const Vector2 rightSide 
)
inline

Add two the components of one Vector to another Vector and return the resulting Vector. Behavior is the same as Vector::operator+

Parameters
leftSideThe Vector object to take the left hand side of the addition operation.
rightSideThe Vector object to take the right hand side of the addition operation.
resultis the result of leftSide + rightSide.
Note
None of the inputs can be null.
float TurtleBrains::Math::Vector2DotProduct ( const Vector2 leftSide,
const Vector2 rightSide 
)
inline

Performs the DotProduct on two Vector objects returning resulting scalar value.

Parameters
leftSideThe Vector object to take the left hand side of the dot product operation.
rightSideThe Vector object to take the right hand side of the dot product operation.
Note
None of the inputs can be null.
float TurtleBrains::Math::Vector2Magnitude ( const Vector2 input)
inline

Computes the length (magnitude) of a Vector object returning resulting scalar value.

Parameters
inputThe Vector object to compute the length of.
Note
The input vector cannot be null.
float TurtleBrains::Math::Vector2MagnitudeSquared ( const Vector2 input)
inline

Computes the length (magnitude) of a Vector object without performing the squareroot, so the resulting scalar is actually the squared length of the Vector.

Parameters
inputThe Vector object to get the squared length of.
Note
The input vector cannot be null.
Vector2* TurtleBrains::Math::Vector2Negate ( Vector2 result,
const Vector2 input 
)
inline

Negates each of the components of a Vector and returns the resulting Vector.

Parameters
resultThe result of negating each component in input.
inputThe Vector object to negate.
Note
None of the inputs can be null.
Vector2* TurtleBrains::Math::Vector2Normalize ( Vector2 result,
const Vector2 input 
)
inline

Calculates the unit-length vector of the input Vector and returns the resulting Vector.

Parameters
inputThe Vector object to get the unit-length of.
resultThe unit length vector from the input, or a zero vector if the input had no length.
Note
The input vector cannot be null.
Vector2* TurtleBrains::Math::Vector2NormalizeMagnitude ( Vector2 result,
const Vector2 input,
float &  magnitude 
)
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.

Parameters
resultThe unit length vector from the input, or a zero vector if the input had no length.
inputThe Vector object to get the unit-length of.
magnitudeThe length of the input vector as it must be computed.
Note
The input vector cannot be null.
Vector2* TurtleBrains::Math::Vector2Scale ( Vector2 result,
const Vector2 input,
const float  scalar 
)
inline

Scales the components of one Vector and returns the resulting Vector.

Parameters
resultThe result of input * scalar.
inputThe Vector object to scale by the scalar value.
scalarThe amount to scale the input Vector by. 2.0f would double the Vectors magnitude.
Note
None of the inputs can be null.
Vector2* TurtleBrains::Math::Vector2ScaleDivide ( Vector2 result,
const Vector2 input,
const float  scalar 
)
inline

Divides the components of one Vector by the scalar and returns the resulting Vector.

Parameters
resultThe result of input * scalar.
inputThe Vector object to scale by the scalar value.
scalarThe amount to inverse scale the input Vector by. 2.0f would half the Vectors magnitude.
Note
None of the inputs can be null.
Vector2* TurtleBrains::Math::Vector2Subtract ( Vector2 result,
const Vector2 leftSide,
const Vector2 rightSide 
)
inline

Subtracts the components of one Vector from another Vector and returns the resulting Vector. Behavior is the same as using Vector::operator-

Parameters
leftSideThe Vector object to take the left hand side of the subtraction operation.
rightSideThe Vector object to take the right hand side of the subtraction operation.
resultis the result of leftSide - rightSide.
Note
None of the inputs can be null.
Vector3* TurtleBrains::Math::Vector3Add ( Vector3 result,
const Vector3 leftSide,
const Vector3 rightSide 
)
inline

Add two the components of one Vector to another Vector and return the resulting Vector. Behavior is the same as Vector::operator+

Parameters
leftSideThe Vector object to take the left hand side of the addition operation.
rightSideThe Vector object to take the right hand side of the addition operation.
resultis the result of leftSide + rightSide.
Note
None of the inputs can be null.
float TurtleBrains::Math::Vector3AngleBetween ( const Vector3 left,
const Vector3 right 
)
inline

Returns angle between vectors in radians, 0 is both pointing same direction, kPi if both vectors are pointing in opposite directions.

Vector3* TurtleBrains::Math::Vector3CrossProduct ( Vector3 result,
const Vector3 leftSide,
const Vector3 rightSide 
)
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.

Parameters
resultThe result of leftSide cross rightSide, also performed with operator^
leftSideThe Vector object to take the left hand side of the cross product operation.
rightSideThe Vector object to take the right hand side of the cross product operation.
Note
None of the input parameters can be null, and result must be different than leftSide and rightSide.
float TurtleBrains::Math::Vector3DotProduct ( const Vector3 leftSide,
const Vector3 rightSide 
)
inline

Performs the DotProduct on two Vector objects returning resulting scalar value.

Parameters
leftSideThe Vector object to take the left hand side of the dot product operation.
rightSideThe Vector object to take the right hand side of the dot product operation.
Note
None of the inputs can be null.
float TurtleBrains::Math::Vector3Magnitude ( const Vector3 input)
inline

Computes the length (magnitude) of a Vector object returning resulting scalar value.

Parameters
inputThe Vector object to compute the length of.
Note
The input vector cannot be null.
float TurtleBrains::Math::Vector3MagnitudeSquared ( const Vector3 input)
inline

Computes the length (magnitude) of a Vector object without performing the squareroot, so the resulting scalar is actually the squared length of the Vector.

Parameters
inputThe Vector object to get the squared length of.
Note
The input vector cannot be null.
Vector3* TurtleBrains::Math::Vector3Negate ( Vector3 result,
const Vector3 input 
)
inline

Negates each of the components of a Vector and returns the resulting Vector.

Parameters
resultThe result of negating each component in input.
inputThe Vector object to negate.
Note
None of the inputs can be null.
Vector3* TurtleBrains::Math::Vector3Normalize ( Vector3 result,
const Vector3 input 
)
inline

Calculates the unit-length vector of the input Vector and returns the resulting Vector.

Parameters
inputThe Vector object to get the unit-length of.
resultThe unit length vector from the input, or a zero vector if the input had no length.
Note
The input vector cannot be null.
Vector3* TurtleBrains::Math::Vector3NormalizeMagnitude ( Vector3 result,
const Vector3 input,
float &  magnitude 
)
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.

Parameters
resultThe unit length vector from the input, or a zero vector if the input had no length.
inputThe Vector object to get the unit-length of.
magnitudeThe length of the input vector as it must be computed.
Note
The input vector cannot be null.
Vector3* TurtleBrains::Math::Vector3Scale ( Vector3 result,
const Vector3 input,
const float  scalar 
)
inline

Scales the components of one Vector and returns the resulting Vector.

Parameters
resultThe result of input * scalar.
inputThe Vector object to scale by the scalar value.
scalarThe amount to scale the input Vector by. 2.0f would double the Vectors magnitude.
Note
None of the inputs can be null.
Vector3* TurtleBrains::Math::Vector3ScaleDivide ( Vector3 result,
const Vector3 input,
const float  scalar 
)
inline

Divides the components of one Vector by the scalar and returns the resulting Vector.

Parameters
resultThe result of input * scalar.
inputThe Vector object to scale by the scalar value.
scalarThe amount to inverse scale the input Vector by. 2.0f would half the Vectors magnitude.
Note
None of the inputs can be null.
Vector3* TurtleBrains::Math::Vector3Subtract ( Vector3 result,
const Vector3 leftSide,
const Vector3 rightSide 
)
inline

Subtracts the components of one Vector from another Vector and returns the resulting Vector. Behavior is the same as using Vector::operator-

Parameters
leftSideThe Vector object to take the left hand side of the subtraction operation.
rightSideThe Vector object to take the right hand side of the subtraction operation.
resultis the result of leftSide - rightSide.
Note
None of the inputs can be null.
Vector3* TurtleBrains::Math::Vector3TransformCoord ( Vector3 result,
const Vector3 inputVector,
const Matrix4 inputMatrix 
)
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 a Vector3 does not have a w component and saves upon that final round of multiplications.

Parameters
resultThe vector to hold the result of the transformed inputVector, must be a different vector object or an error condition will be triggered.
inputVectorThe vector to transform by the input matrix, must not be the same as result.
inputMatrixThe transform matrix to multiply inputVector by.
Vector3* TurtleBrains::Math::Vector3TransformNormal ( Vector3 result,
const Vector3 inputVector,
const Matrix4 inputMatrix 
)
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 differently than Vector3TransformCoord because it does not consider the translation of the matrix, only the rotation.

Parameters
resultThe vector to hold the result of the transformed inputVector, must be a different vector object or an error condition will be triggered.
inputVectorThe vector to transform by the input matrix, must not be the same as result.
inputMatrixThe transform matrix to multiply inputVector by.
Vector4* TurtleBrains::Math::Vector4Add ( Vector4 result,
const Vector4 leftSide,
const Vector4 rightSide 
)
inline

Add two the components of one Vector to another Vector and return the resulting Vector. Behavior is the same as Vector::operator+

Parameters
leftSideThe Vector object to take the left hand side of the addition operation.
rightSideThe Vector object to take the right hand side of the addition operation.
resultis the result of leftSide + rightSide.
Note
None of the inputs can be null.
Vector4* TurtleBrains::Math::Vector4CrossProduct ( Vector4 result,
const Vector4 leftSide,
const Vector4 rightSide 
)
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.

Parameters
resultThe result of leftSide cross rightSide, also performed with operator^
leftSideThe Vector object to take the left hand side of the cross product operation.
rightSideThe Vector object to take the right hand side of the cross product operation.
Note
None of the input parameters can be null, and result must be different than leftSide and rightSide.
Currently unsure if this is accurate, so it is implemented but will throw an error upon use.
float TurtleBrains::Math::Vector4DotProduct ( const Vector4 leftSide,
const Vector4 rightSide 
)
inline

Performs the DotProduct on two Vector objects returning resulting scalar value.

Parameters
leftSideThe Vector object to take the left hand side of the dot product operation.
rightSideThe Vector object to take the right hand side of the dot product operation.
Note
None of the inputs can be null.
float TurtleBrains::Math::Vector4Magnitude ( const Vector4 input)
inline

Computes the length (magnitude) of a Vector object returning resulting scalar value.

Parameters
inputThe Vector object to compute the length of.
Note
The input vector cannot be null.
float TurtleBrains::Math::Vector4MagnitudeSquared ( const Vector4 input)
inline

Computes the length (magnitude) of a Vector object without performing the squareroot, so the resulting scalar is actually the squared length of the Vector.

Parameters
inputThe Vector object to get the squared length of.
Note
The input vector cannot be null.
Vector4* TurtleBrains::Math::Vector4MatrixMultiply ( Vector4 result,
const Vector4 inputVector,
const Matrix4 inputMatrix 
)
inline

Multiplies a vector and matrix together to transform the inputVector into the space described by the inputMatrix storing and returning the result.

Parameters
resultThe vector to hold the result of the transformed inputVector, must be a different vector object or an error condition will be triggered.
inputVectorThe vector to transform by the input matrix, must not be the same as result.
inputMatrixThe transform matrix to multiply inputVector by.
Vector4* TurtleBrains::Math::Vector4Negate ( Vector4 result,
const Vector4 input 
)
inline

Negates each of the components of a Vector and returns the resulting Vector.

Parameters
resultThe result of negating each component in input.
inputThe Vector object to negate.
Note
None of the inputs can be null.
Vector4* TurtleBrains::Math::Vector4Normalize ( Vector4 result,
const Vector4 input 
)
inline

Calculates the unit-length vector of the input Vector and returns the resulting Vector.

Parameters
inputThe Vector object to get the unit-length of.
resultThe unit length vector from the input, or a zero vector if the input had no length.
Note
The input vector cannot be null.
Vector4* TurtleBrains::Math::Vector4NormalizeMag ( Vector4 result,
const Vector4 input,
float &  magnitude 
)
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.

Parameters
resultThe unit length vector from the input, or a zero vector if the input had no length.
inputThe Vector object to get the unit-length of.
magnitudeThe length of the input vector as it must be computed.
Note
The input vector cannot be null.
Vector4* TurtleBrains::Math::Vector4Scale ( Vector4 result,
const Vector4 input,
const float  scalar 
)
inline

Scales the components of one Vector and returns the resulting Vector.

Parameters
resultThe result of input * scalar.
inputThe Vector object to scale by the scalar value.
scalarThe amount to scale the input Vector by. 2.0f would double the Vectors magnitude.
Note
None of the inputs can be null.
Vector4* TurtleBrains::Math::Vector4ScaleDivide ( Vector4 result,
const Vector4 input,
const float  scalar 
)
inline

Divides the components of one Vector by the scalar and returns the resulting Vector.

Parameters
resultThe result of input * scalar.
inputThe Vector object to scale by the scalar value.
scalarThe amount to inverse scale the input Vector by. 2.0f would half the Vectors magnitude.
Note
None of the inputs can be null.
Vector4* TurtleBrains::Math::Vector4Subtract ( Vector4 result,
const Vector4 leftSide,
const Vector4 rightSide 
)
inline

Subtracts the components of one Vector from another Vector and returns the resulting Vector. Behavior is the same as using Vector::operator-

Parameters
leftSideThe Vector object to take the left hand side of the subtraction operation.
rightSideThe Vector object to take the right hand side of the subtraction operation.
resultis the result of leftSide - rightSide.
Note
None of the inputs can be null.