Contains routines for vector and matrix manipulation. More...
Go to the source code of this file.
Macros | |
#define | FBSDK_DLL K_DLLIMPORT |
Be sure that FBSDK_DLL is defined only once... | |
Enumerations | |
enum | FBRotationOrder { kFBXYZ , kFBXZY , kFBYXZ , kFBYZX , kFBZXY , kFBZYX } |
Specify the Euler rotation order. More... | |
Functions | |
FB_DEFINE_ENUM (K_DLLIMPORT, RotationOrder) | |
K_DLLIMPORT void | FBMatrixInverse (FBMatrix &pMatrix, const FBMatrix &pSrc) |
Invert a matrix. | |
K_DLLIMPORT void | FBMatrixTranspose (FBMatrix &pMatrix, const FBMatrix &pSrc) |
Transpose a matrix. | |
K_DLLIMPORT void | FBMatrixMult (FBMatrix &pMatrix, const FBMatrix &pA, const FBMatrix &pB) |
Multiply two matrices. | |
K_DLLIMPORT void | FBVertexMatrixMult (FBVertex &pOutVertex, const FBMatrix &pMatrix, const FBVertex &pVertex) |
Multiply a vertex by a matrix. | |
K_DLLIMPORT void | FBVectorMatrixMult (FBVector4d &pOutVector, const FBMatrix &pMatrix, const FBVector4d &pVector) |
Multiply a vector by a matrix. | |
K_DLLIMPORT void | FBTranslationToMatrix (FBMatrix &pMatrix, const FBTVector &pVector) |
Convert a translation vector to a matrix. | |
K_DLLIMPORT void | FBRotationToMatrix (FBMatrix &pMatrix, const FBRVector &pVector, FBRotationOrder pRotationOrder=kFBXYZ) |
Convert a rotation vector to a matrix. | |
K_DLLIMPORT void | FBScalingToMatrix (FBMatrix &pMatrix, const FBSVector &pVector) |
Convert a scaling vector to a matrix. | |
K_DLLIMPORT void | FBTRSToMatrix (FBMatrix &pMatrix, const FBTVector &pTVector, const FBRVector &pRVector, const FBSVector &pSVector) |
Convert translation, rotation, and scaling vectors to a matrix. | |
K_DLLIMPORT void | FBTQSToMatrix (FBMatrix &pMatrix, const FBTVector &pTVector, const FBQuaternion &pQuaternion, const FBSVector &pSVector) |
Convert translation vector, rotation quaternion, and scaling vector to a matrix. | |
K_DLLIMPORT void | FBMatrixToTranslation (FBTVector &pVector, const FBMatrix &pMatrix) |
Obtain translation vector from a matrix. | |
K_DLLIMPORT void | FBMatrixToRotation (FBRVector &pVector, const FBMatrix &pMatrix, FBRotationOrder pRotationOrder=kFBXYZ) |
Obtain rotation vector from a matrix. | |
K_DLLIMPORT void | FBMatrixToScaling (FBSVector &pVector, const FBMatrix &pMatrix) |
Obtain scaling vector from a matrix. | |
K_DLLIMPORT void | FBMatrixToTRS (FBTVector &pTVector, FBRVector &pRVector, FBSVector &pSVector, const FBMatrix &pMatrix) |
Obtain translation, rotation, and scaling vectors from a matrix. | |
K_DLLIMPORT void | FBMatrixToTQS (FBTVector &pTVector, FBQuaternion &pQuaternion, FBSVector &pSVector, const FBMatrix &pMatrix) |
Obtain translation vector, rotation quaternion, and scaling vector from a matrix. | |
K_DLLIMPORT void | FBRotationToQuaternion (FBQuaternion &pQuaternion, const FBRVector &pVector, FBRotationOrder pRotationOrder=kFBXYZ) |
Get a quaternion from a rotation vector. | |
K_DLLIMPORT void | FBQuaternionToRotation (FBRVector &pVector, const FBQuaternion &pQuaternion, FBRotationOrder pRotationOrder=kFBXYZ) |
Get a rotation vector from a quaternion vector. | |
K_DLLIMPORT void | FBMatrixToQuaternion (FBQuaternion &pQuaternion, const FBMatrix &pMatrix) |
Get a quaternion from a matrix (potential ). | |
K_DLLIMPORT void | FBQuaternionToMatrix (FBMatrix &pMatrix, const FBQuaternion &pQuaternion) |
Get a rotation matrix from a quaternion vector. | |
K_DLLIMPORT void | FBGetLocalMatrix (FBMatrix &pMatrix, const FBMatrix &pMatrixParent, const FBMatrix &pMatrixChild) |
Get local matrix from parent and child matrices. | |
K_DLLIMPORT void | FBGetGlobalMatrix (FBMatrix &pMatrix, const FBMatrix &pMatrixParent, const FBMatrix &pLocalMatrix) |
Get global matrix from parent and child matrices. | |
K_DLLIMPORT void | FBMatrixOrthogonalize (FBMatrix &pMatrix) |
Make sure that rotation vectors are orthogonal and normalized (fast way for removing scaling from matrix) | |
K_DLLIMPORT void | FBAdd (FBTVector &pResult, const FBTVector &pV1, const FBTVector &pV2) |
Add two vectors together (pResult = pV1 + pV2) | |
K_DLLIMPORT void | FBSub (FBTVector &pResult, const FBTVector &pV1, const FBTVector &pV2) |
Subtract pV2 from pV1 (pResult = pV1 - pV2) | |
K_DLLIMPORT void | FBMult (FBTVector &pResult, const FBTVector &pV1, double pV2) |
Multiply pV2 from pV1 (pResult = pV1 * pV2) | |
K_DLLIMPORT void | FBMult (FBTVector &pResult, const FBTVector &pV1, const FBTVector &pV2) |
Calculate the cross product of two vectors. | |
K_DLLIMPORT void | FBMult (FBMatrix &pResult, const FBMatrix &pM, const FBSVector &pV) |
Calculate the cross product of a Matrix and Scale Vector. | |
K_DLLIMPORT double | FBDot (const FBTVector &pV1, const FBTVector &pV2) |
Calculate the dot product of two vectors. | |
K_DLLIMPORT double | FBLength (const FBTVector &pV) |
Get the length of a vector. | |
K_DLLIMPORT void | FBQAdd (FBQuaternion &pResult, const FBQuaternion &pQ1, const FBQuaternion &pQ2) |
Add two quaternions together (pResult = pQ1 + pQ2) | |
K_DLLIMPORT void | FBQSub (FBQuaternion &pResult, const FBQuaternion &pQ1, const FBQuaternion &pQ2) |
Subtract pQ2 from pQ1 (pResult = pQ1 - pQ2) | |
K_DLLIMPORT void | FBQMult (FBQuaternion &pResult, const FBQuaternion &pQ1, double pQ2) |
Multiply pQ2 from pQ1 (pResult = pQ1 * pQ2) | |
K_DLLIMPORT void | FBQMult (FBQuaternion &pResult, const FBQuaternion &pQ1, const FBQuaternion &pQ2) |
Calculate the cross product of two quaternions. | |
K_DLLIMPORT double | FBQDot (const FBQuaternion &pQ1, const FBQuaternion &pQ2) |
Calculate the dot product of two quaternions. | |
K_DLLIMPORT double | FBQLength (const FBQuaternion &pQ) |
Get the length of a quaternion. | |
K_DLLIMPORT double | FBLength (const FBVertex &pV) |
Get the length of a vertex (from origin) | |
K_DLLIMPORT void | FBInterpolateRotation (FBRVector &pROut, const FBRVector &pR0, const FBRVector &pR1, double pU) |
Interpolate a rotation in Euler space. | |
K_DLLIMPORT void | FBInterpolateRotation (FBQuaternion &pQOut, const FBQuaternion &pQ0, const FBQuaternion &pQ1, double pU) |
Interpolate a rotation in Quaternion. | |
K_DLLIMPORT void | FBGetContinuousRotation (FBRVector &pROut, const FBRVector &pR0, const FBRVector &pR1) |
Get a continuous rotation in Euler space. | |
K_DLLIMPORT double | FBClamp (double pV, double pL, double pH) |
Clamp value. | |
K_DLLIMPORT void | FBBigEndianToNative (unsigned short &pV) |
Change from big endian to native format. | |
K_DLLIMPORT void | FBLittleEndianToNative (unsigned short &pV) |
Change from little endian to native format. | |
K_DLLIMPORT void | FBMatrixToRotationWithPrecision (FBRVector &pVector, const FBMatrix &pMatrix, FBRotationOrder pRotationOrder, double pPrecision=FBMat2EulerDegenerateForPrecision10) |
Obtain rotation vector from a matrix. | |
K_DLLIMPORT void | FBQuaternionToRotationWithPrecision (FBRVector &pVector, const FBQuaternion &pQuaternion, FBRotationOrder pRotationOrder, double pPrecision=FBMat2EulerDegenerateForPrecision10) |
Get a rotation vector from a quaternion vector. | |
Variables | |
const double | FBMat2EulerDegenerateForPrecision10 = 16.0e-10 |
Contains routines for vector and matrix manipulation.
Definition in file fbmath.h.
#define FBSDK_DLL K_DLLIMPORT |
enum FBRotationOrder |
Add two vectors together (pResult = pV1 + pV2)
pResult | Resulting vector. |
pV1 | 1st vector. |
pV2 | 2nd vector. |
K_DLLIMPORT void FBBigEndianToNative | ( | unsigned short & | pV | ) |
Change from big endian to native format.
pV | Value to modify. |
K_DLLIMPORT double FBClamp | ( | double | pV, |
double | pL, | ||
double | pH | ||
) |
Clamp value.
pV | Value to clamp. |
pL | Low limit. |
pH | High limit. |
Calculate the dot product of two vectors.
pV1 | 1st vector. |
pV2 | 2nd vector. |
K_DLLIMPORT void FBGetContinuousRotation | ( | FBRVector & | pROut, |
const FBRVector & | pR0, | ||
const FBRVector & | pR1 | ||
) |
Get a continuous rotation in Euler space.
This routine will help to avoid gimble locks due to interpolation.
pROut | Successful continuous rotation (gimble-lock free). |
pR0 | Suggested next rotation. |
pR1 | Previous rotation. |
K_DLLIMPORT void FBGetGlobalMatrix | ( | FBMatrix & | pMatrix, |
const FBMatrix & | pMatrixParent, | ||
const FBMatrix & | pLocalMatrix | ||
) |
Get global matrix from parent and child matrices.
From an input referential, this function will calculate the global matrix corresponding to the input local matrix (which is with respect to the parent matrix).
pMatrix | Calculated local matrix. |
pMatrixParent | Parent matrix. |
pLocalMatrix | Local matrix. |
K_DLLIMPORT void FBGetLocalMatrix | ( | FBMatrix & | pMatrix, |
const FBMatrix & | pMatrixParent, | ||
const FBMatrix & | pMatrixChild | ||
) |
Get local matrix from parent and child matrices.
Will calculate the local matrix from two global matrices. The resulting matrix will be a local matrix containing the local transformations to go from the parent referentialto the child referential.
pMatrix | Calculated local matrix. |
pMatrixParent | Parent matrix (new base referential). |
pMatrixChild | Child matrix. |
K_DLLIMPORT void FBInterpolateRotation | ( | FBQuaternion & | pQOut, |
const FBQuaternion & | pQ0, | ||
const FBQuaternion & | pQ1, | ||
double | pU | ||
) |
Interpolate a rotation in Quaternion.
pQOut | Resulting, interpolated rotation. |
pQ0 | 1st rotation. |
pQ1 | 2nd rotation. |
pU | Interpolation ratio. |
K_DLLIMPORT void FBInterpolateRotation | ( | FBRVector & | pROut, |
const FBRVector & | pR0, | ||
const FBRVector & | pR1, | ||
double | pU | ||
) |
Interpolate a rotation in Euler space.
pROut | Resulting, interpolated rotation. |
pR0 | 1st rotation. |
pR1 | 2nd rotation. |
pU | Interpolation ratio. |
K_DLLIMPORT double FBLength | ( | const FBTVector & | pV | ) |
Get the length of a vector.
pV | Vector to calculate length for. |
K_DLLIMPORT double FBLength | ( | const FBVertex & | pV | ) |
Get the length of a vertex (from origin)
pV | Vertex for which length is to be measured. |
K_DLLIMPORT void FBLittleEndianToNative | ( | unsigned short & | pV | ) |
Change from little endian to native format.
pV | Value to modify. |
Invert a matrix.
pMatrix | Calculated inverse matrix. |
pSrc | Source matrix to invert. |
Multiply two matrices.
pMatrix | Calculated resulting matrix. |
pA | 1st matrix. |
pB | 2nd matrix. |
K_DLLIMPORT void FBMatrixOrthogonalize | ( | FBMatrix & | pMatrix | ) |
Make sure that rotation vectors are orthogonal and normalized (fast way for removing scaling from matrix)
pMatrix | Orthogonalized matrix. |
pMatrix | Rotation Matrix to Orthogonalize. |
K_DLLIMPORT void FBMatrixToQuaternion | ( | FBQuaternion & | pQuaternion, |
const FBMatrix & | pMatrix | ||
) |
Get a quaternion from a matrix (potential ).
pQuaternion | Calculated quaternion. |
pMatrix | Input matrix. |
K_DLLIMPORT void FBMatrixToRotation | ( | FBRVector & | pVector, |
const FBMatrix & | pMatrix, | ||
FBRotationOrder | pRotationOrder = kFBXYZ |
||
) |
Obtain rotation vector from a matrix.
pVector | Extracted rotation vector, ordered the same way as the rotation order specified by pRotationOrder. |
pMatrix | Input matrix. |
pRotationOrder | Rotation order. |
K_DLLIMPORT void FBMatrixToRotationWithPrecision | ( | FBRVector & | pVector, |
const FBMatrix & | pMatrix, | ||
FBRotationOrder | pRotationOrder, | ||
double | pPrecision = FBMat2EulerDegenerateForPrecision10 |
||
) |
Obtain rotation vector from a matrix.
pVector | Extracted rotation vector. |
pMatrix | Input matrix. |
pRotationOrder | Rotation Order. |
pPrecision | Indicate the precision level (pow(10.0, -pPrecision)) used when calculating the threshold value for gimble lock. |
Obtain scaling vector from a matrix.
pVector | Extracted scaling vector. |
pMatrix | Input matrix. |
K_DLLIMPORT void FBMatrixToTQS | ( | FBTVector & | pTVector, |
FBQuaternion & | pQuaternion, | ||
FBSVector & | pSVector, | ||
const FBMatrix & | pMatrix | ||
) |
Obtain translation vector, rotation quaternion, and scaling vector from a matrix.
pTVector | Extracted translation vector. |
pQuaternion | Extracted rotation quaternion. |
pSVector | Extracted scaling vector. |
pMatrix | Input matrix. |
Obtain translation vector from a matrix.
pVector | Extracted translation vector. |
pMatrix | Input matrix. |
K_DLLIMPORT void FBMatrixToTRS | ( | FBTVector & | pTVector, |
FBRVector & | pRVector, | ||
FBSVector & | pSVector, | ||
const FBMatrix & | pMatrix | ||
) |
Obtain translation, rotation, and scaling vectors from a matrix.
pTVector | Extracted translation vector. |
pRVector | Extracted rotation vector. |
pSVector | Extracted scaling vector. |
pMatrix | Input matrix. |
Transpose a matrix.
pMatrix | Calculated transpose matrix. |
pSrc | Source matrix to transpose. |
Calculate the cross product of a Matrix and Scale Vector.
pResult | Resulting Matrix. |
pM | Matrix. |
pV | vector. |
Calculate the cross product of two vectors.
pResult | Resulting vector. |
pV1 | 1st vector. |
pV2 | 2nd vector. |
Multiply pV2 from pV1 (pResult = pV1 * pV2)
pResult | Resulting vector. |
pV1 | 1st vector. |
pV2 | 2nd vector. |
K_DLLIMPORT void FBQAdd | ( | FBQuaternion & | pResult, |
const FBQuaternion & | pQ1, | ||
const FBQuaternion & | pQ2 | ||
) |
Add two quaternions together (pResult = pQ1 + pQ2)
pResult | Resulting quaternion. |
pQ1 | 1st quaternion. |
pQ2 | 2nd quaternion. |
K_DLLIMPORT double FBQDot | ( | const FBQuaternion & | pQ1, |
const FBQuaternion & | pQ2 | ||
) |
Calculate the dot product of two quaternions.
pQ1 | 1st quaternion. |
pQ2 | 2nd quaternion. |
K_DLLIMPORT double FBQLength | ( | const FBQuaternion & | pQ | ) |
Get the length of a quaternion.
pQ | Quaternion to calculate length for. |
K_DLLIMPORT void FBQMult | ( | FBQuaternion & | pResult, |
const FBQuaternion & | pQ1, | ||
const FBQuaternion & | pQ2 | ||
) |
Calculate the cross product of two quaternions.
pResult | Resulting quaternion. |
pQ1 | 1st quaternion. |
pQ2 | 2nd quaternion. |
K_DLLIMPORT void FBQMult | ( | FBQuaternion & | pResult, |
const FBQuaternion & | pQ1, | ||
double | pQ2 | ||
) |
Multiply pQ2 from pQ1 (pResult = pQ1 * pQ2)
pResult | Resulting quaternion. |
pQ1 | 1st quaternion. |
pQ2 | 2nd quaternion. |
K_DLLIMPORT void FBQSub | ( | FBQuaternion & | pResult, |
const FBQuaternion & | pQ1, | ||
const FBQuaternion & | pQ2 | ||
) |
Subtract pQ2 from pQ1 (pResult = pQ1 - pQ2)
pResult | Resulting quaternion. |
pQ1 | 1st quaternion. |
pQ2 | 2nd quaternion. |
K_DLLIMPORT void FBQuaternionToMatrix | ( | FBMatrix & | pMatrix, |
const FBQuaternion & | pQuaternion | ||
) |
Get a rotation matrix from a quaternion vector.
pMatrix | Calculated rotation matrix. |
pQuaternion | Input quaternion. |
K_DLLIMPORT void FBQuaternionToRotation | ( | FBRVector & | pVector, |
const FBQuaternion & | pQuaternion, | ||
FBRotationOrder | pRotationOrder = kFBXYZ |
||
) |
Get a rotation vector from a quaternion vector.
pVector | Calculated rotation vector, ordered the same way as the rotation order specified by pRotationOrder. |
pQuaternion | Input quaternion. |
pRotationOrder | Rotation order. |
K_DLLIMPORT void FBQuaternionToRotationWithPrecision | ( | FBRVector & | pVector, |
const FBQuaternion & | pQuaternion, | ||
FBRotationOrder | pRotationOrder, | ||
double | pPrecision = FBMat2EulerDegenerateForPrecision10 |
||
) |
Get a rotation vector from a quaternion vector.
pVector | Calculated rotation vector. |
pQuaternion | Input quaternion. |
pRotationOrder | Rotation order of the rotation vector. |
pPrecision | Indicate the precision level (pow(10.0, -pPrecision)) used when calculating the threshold value for gimble lock. |
K_DLLIMPORT void FBRotationToMatrix | ( | FBMatrix & | pMatrix, |
const FBRVector & | pVector, | ||
FBRotationOrder | pRotationOrder = kFBXYZ |
||
) |
Convert a rotation vector to a matrix.
pMatrix | Calculated resulting matrix. |
pVector | Rotation vector, ordered the same way as the rotation order specified by pRotationOrder. |
pRotationOrder | Rotation order. |
K_DLLIMPORT void FBRotationToQuaternion | ( | FBQuaternion & | pQuaternion, |
const FBRVector & | pVector, | ||
FBRotationOrder | pRotationOrder = kFBXYZ |
||
) |
Get a quaternion from a rotation vector.
pQuaternion | Calculated quaternion. |
pVector | Input rotation vector, ordered the same way as the rotation order specified by pRotationOrder. |
pRotationOrder | Rotation order. |
Convert a scaling vector to a matrix.
pMatrix | Calculated resulting matrix. |
pVector | Scaling vector. |
Subtract pV2 from pV1 (pResult = pV1 - pV2)
pResult | Resulting vector. |
pV1 | 1st vector. |
pV2 | 2nd vector. |
K_DLLIMPORT void FBTQSToMatrix | ( | FBMatrix & | pMatrix, |
const FBTVector & | pTVector, | ||
const FBQuaternion & | pQuaternion, | ||
const FBSVector & | pSVector | ||
) |
Convert translation vector, rotation quaternion, and scaling vector to a matrix.
pMatrix | Calculated resulting matrix. |
pTVector | Translation vector. |
pQuaternion | Rotation quaternion. |
pSVector | Scaling vector. |
Convert a translation vector to a matrix.
pMatrix | Calculated resulting matrix. |
pVector | Translation vector. |
K_DLLIMPORT void FBTRSToMatrix | ( | FBMatrix & | pMatrix, |
const FBTVector & | pTVector, | ||
const FBRVector & | pRVector, | ||
const FBSVector & | pSVector | ||
) |
Convert translation, rotation, and scaling vectors to a matrix.
pMatrix | Calculated resulting matrix. |
pTVector | Translation vector. |
pRVector | Rotation vector. |
pSVector | Scaling vector. |
K_DLLIMPORT void FBVectorMatrixMult | ( | FBVector4d & | pOutVector, |
const FBMatrix & | pMatrix, | ||
const FBVector4d & | pVector | ||
) |
Multiply a vector by a matrix.
pOutVector | Resulting vector. |
pMatrix | Matrix to affect the vector with. |
pVector | Source vector. |
K_DLLIMPORT void FBVertexMatrixMult | ( | FBVertex & | pOutVertex, |
const FBMatrix & | pMatrix, | ||
const FBVertex & | pVertex | ||
) |
Multiply a vertex by a matrix.
pOutVertex | Resulting vertex. |
pMatrix | Matrix to affect the vertex with. |
pVertex | Source vertex. |