nn::math Namespace

Description

Namespace for numerical calculations.

Structures

nn::math::MTX22 A 2x2 matrix class.
nn::math::MTX23 A 2x3 matrix class.
nn::math::MTX33 A 3x3 matrix class.
nn::math::MTX34 A 3x4 matrix class.
nn::math::MTX43 A 4x3 matrix class.
nn::math::MTX44 A 4x4 matrix class.
nn::math::VEC2 A two-dimensional vector class.
nn::math::VEC3 A three-dimensional vector class.
nn::math::VEC4 A four-dimensional vector class.

Enumerated Types

Matrix
PivotDirection Enumerated type for specifying the rotation matrix to multiply the projection matrix by.

Functions

Matrices
MTX43Copy Copies a matrix.
MTX43Add Calculates the sum of two matrices.
MTX43Mult Calculates the product of two matrices.
MTX44PerspectiveDeg Creates a projection matrix based on a field-of-view angle and an aspect ratio.
MTX44PerspectivePivotDeg Creates a projection matrix based on a field-of-view angle and an aspect ratio.
MTX44RotXYZRad Creates a rotation matrix.
MTX44RotXYZDeg Creates a rotation matrix.
MTX44RotAxisRad Creates a rotation matrix for rotating around the specified axis.
MTX44RotAxisDeg Creates a rotation matrix for rotating around the specified axis.
MTX22IsIdentity Determines whether a matrix is an identity matrix.
MTX22Copy Copies a 2x2 matrix.
MTX22Zero Creates a zero matrix.
MTX22Identity Creates a 2x2 identity matrix.
MTX22MAdd Multiplies a matrix by a real number and adds a separate matrix to the product.
MTX23Copy Copies a 2x3 matrix.
MTX23Zero Creates a zero matrix.
MTX23Identity Creates a 2x3 identity matrix.
MTX23IsIdentity Determines whether a matrix is an identity matrix.
MTX23Add Adds two 2x3 matrices.
MTX23Sub Subtracts a 2x3 matrix from a 2x3 matrix.
MTX23Mult Calculates the scalar product of a 2x3 matrix.
MTX23Scale Scales a 2x3 matrix.
MTX23Translate Translates a 2x3 matrix. Postmultiplies the input matrix by the translation matrix.
MTX23RotFIdx Creates a rotation matrix.
MTX23RotCenterFIdx Creates a rotation matrix having the specified center of rotation.
MTX23MAdd Multiplies a matrix by a real number and adds a separate matrix to the product.
MTX22ToMTX23 Copies a 2x2 matrix to a 2x3 matrix.
MTX33IsIdentity Determines whether a matrix is an identity matrix.
MTX33Zero Creates a zero matrix.
MTX33Identity Creates an identity matrix.
MTX34Zero Creates a zero matrix.
MTX34Identity Creates an identity matrix.
MTX34IsIdentity Determines whether a matrix is an identity matrix.
MTX34Sub Calculates the difference of two matrices.
MTX34RotAxisFIdx Creates a rotation matrix for rotating around the specified axis.
MTX34RotXYZTranslateFIdx Produces a matrix that is the result of premultiplying a rotation matrix by a translation matrix.
MTX34InvTranspose Calculates the inverse transpose of a 3x4 matrix and stores it in a 3x3 matrix.
MTX34MultArray Premultiplies an array of matrices by another matrix.
MTX34TextureProjectionFrustum Creates a texture projection matrix based on the viewing frustum.
MTX34TextureProjectionPerspective Creates a texture projection matrix.
MTX34TextureProjectionOrtho Creates an orthogonal texture projection matrix.
MTX43IsIdentity Determines whether a matrix is an identity matrix.
MTX43Zero Creates a zero matrix.
MTX43Identity Creates an identity matrix.
MTX43Sub Calculates the difference of two matrices.
MTX44Zero Creates a zero matrix.
MTX44Identity Creates an identity matrix.
MTX44Sub Calculates the difference of two matrices.
MTX44IsIdentity Determines whether a matrix is an identity matrix.
MTX44FrustumPivot Creates a projection matrix that has been multiplied by a screen rotation. Creates a projection matrix based on the viewing frustum at the near clipping plane.
MTX44OrthoPivot Creates a projection matrix that has been multiplied by a screen rotation. Creates an orthographic projection matrix.
MTX44PerspectivePivotRad Creates a projection matrix that has been multiplied by a screen rotation. Creates a projection matrix based on a field-of-view angle and an aspect ratio.
MTX44MultArray Premultiplies an array of matrices by another matrix.
MTX44RotAxisFIdx Creates a rotation matrix for rotating around the specified axis.
MTX33Mult Calculates the product of two 3x3 matrices.
MTX33Copy Copies a 3x3 matrix.
MTX33MAdd Multiplies a matrix by a real number and adds a separate matrix to the product.
MTX34Copy Copies a matrix.
MTX34Add Calculates the sum of two matrices.
MTX34Mult Calculates the scalar product of a matrix.
MTX34MAdd Multiplies a matrix by a real number and adds a separate matrix to the product.
MTX34Inverse Calculates the inverse of a matrix.
MTX34Transpose Creates the transpose of a matrix.
MTX34LookAt Sets the camera matrix.
MTX34CameraRotate Sets the camera matrix.
MTX34RotXYZFIdx Creates a rotation matrix.
MTX34Scale Creates a matrix to use for scaling transformations.
MTX34MultScale Scales a matrix. Postmultiplies the input matrix by the scaling vector.
MTX34Translate Creates a translation matrix.
MTX34MultTranslate Translates a matrix. Postmultiplies the input matrix by the translation vector.
MTX34RotAxisRad_ Creates a rotation matrix for rotating around the specified axis.
MTX34RotXYZRad Creates a rotation matrix.
MTX34RotXYZDeg Creates a rotation matrix.
MTX34RotAxisRad Creates a rotation matrix for rotating around the specified axis.
MTX34RotAxisDeg Creates a rotation matrix for rotating around the specified axis.
MTX44Copy Copies a matrix.
MTX44Add Calculates the sum of two matrices.
MTX44Mult Calculates the scalar product of a matrix.
MTX44Frustum Creates a projection matrix based on the viewing frustum at the near clipping plane.

Note: The order of the arguments follows the OpenGL standard.
MTX44Ortho Creates an orthographic projection matrix.

Note: The order of the arguments follows the OpenGL standard.
MTX44PerspectiveRad Creates a projection matrix based on a field-of-view angle and an aspect ratio.
MTX44Transpose Creates the transpose of a matrix.
MTX44Inverse Calculates the inverse of a matrix.
MTX44RotXYZFIdx Creates a rotation matrix.
MTX44Scale Creates a matrix to use for scaling transformations.
MTX44MultScale Scales a matrix. Postmultiplies the input matrix by the scaling vector.
MTX44Translate Creates a translation matrix.
MTX44MultTranslate Translates a matrix. Postmultiplies the input matrix by the translation vector.
MTX44RotAxisRad_ Creates a rotation matrix for rotating around the specified axis.
MTX43Transpose Gets the transpose of a 4x3 matrix, resulting in a 3x4 matrix.
Quaternions
QUATAdd Calculates the sum of two quaternions.
QUATSub Calculates the result of quaternion subtraction.
QUATDivide Calculates the quotient of two quaternions.
QUATDot Calculates the dot product of two quaternions.
QUATScale Multiplies a quaternion by a real number.
QUATExp Calculates the base of the natural logarithm (the constant e) raised to the power of a quaternion.
QUATLogN Calculates the natural logarithm of a quaternion.
QUATLerp Calculates the linear interpolation between two quaternions.
QUATSlerp Calculates the spherical linear interpolation between two quaternions.
QUATSquad Calculates the spherical cubic interpolation between two quaternions.
QUATMakeClosest Modifies q so it is on the same side of the hypersphere as qto.
QUATRotAxisRad Configures a quaternion to perform a rotation around an arbitrary axis defined by the (x, y, z) components of axis.
QUATToMTX34 Creates a rotation matrix from a quaternion.
QUATInverse Calculates the inverse of a quaternion.
QUATMult Calculates the product of two quaternions.
QUATNormalize Normalizes a quaternion.
Utilities
MTX23ToMTX22 Copies a 2x3 matrix to a 2x2 matrix.
VEC2Transform Transforms a two-dimensional vector using a matrix.
VEC3TransformArray Transforms a vector array using a matrix. The fourth element of each vector is taken as 1 during calculation.
VEC3TransformNormal Transforms a vector using a matrix. The fourth element of the vector is taken as 0 during calculation.
VEC3TransformNormalArray Transforms a vector array using a matrix. The fourth element of each vector is taken as 0 during calculation.
VEC3TransformCoord Transforms a vector using a matrix. The fourth element of the vector is taken as 1 during calculation. After calculation, the first, second, and third elements are divided by the fourth element to create a three-dimensional vector that is stored in pOut.
VEC3TransformCoordArray Transforms a vector array using a matrix. The fourth element of each vector is taken as 1 during calculation. After calculation, the first, second, and third elements in each vector are divided by the fourth element to create three-dimensional vectors that are stored in pOut.
VEC4Transform Transforms a vector using a matrix.
VEC4TransformArray Transforms a vector array using a matrix.
MTX34ToMTX33 Copies a 3x4 matrix to a 3x3 matrix.
MTX33ToMTX34 Copies a 3x3 matrix to a 3x4 matrix.
MTX34ToQUAT Creates a quaternion from a rotation matrix.
VEC3Transform Transforms a vector using a matrix.
Vectors
VEC2IsZero Determines whether a vector is the zero vector.
VEC2Maximize Creates the vector formed by the larger of each component of two input vectors.
VEC2Minimize Creates the vector formed by the smaller of each component of two input vectors.
VEC2Normalize Normalizes a vector.
VEC2SafeNormalize Normalizes a vector. If normalization fails, sets the specified vector.
VEC3IsZero Determines whether a vector is the zero vector.
VEC3Maximize Creates the vector formed by the larger of each component of two input vectors.
VEC3Minimize Creates the vector formed by the smaller of each component of two input vectors.
VEC3Cross Calculates the cross product of two vectors.
VEC3SafeNormalize Normalizes a vector. If normalization fails, sets the specified vector.
VEC3SquareDist Calculates the square of the distance between two vectors.
VEC4IsZero Determines whether a vector is the zero vector.
VEC4IsZeroWOne Determines whether a vector is the zero vector in homogeneous coordinates.
VEC4Add Calculates the resultant vector (the result of vector addition).
VEC4Sub Calculates the result of vector subtraction.
VEC4Mult Calculates the product of two vectors.
VEC4Scale Calculates a scalar multiple of a vector.
VEC4Lerp Calculates the linear interpolation between two vectors.
VEC4Dot Calculates the dot product of two vectors.
VEC4LenSq Calculates the square of a vector length.
VEC4Len Calculates the vector length.
VEC4Normalize Normalizes a vector.
VEC4SafeNormalize Normalizes a vector. If normalization fails, sets the specified vector.
VEC4DistSq Calculates the square of the distance between two vectors.
VEC4Maximize Creates the vector formed by the larger of each component of two input vectors.
VEC4Minimize Creates the vector formed by the smaller of each component of two input vectors.
VEC2Lerp Calculates the linear interpolation between vectors.
VEC2Dot Calculates the dot product of two vectors.
VEC2DistSq Calculates the square of the distance between two vectors.
VEC2Add Calculates the resultant vector (the result of vector addition).
VEC2Sub Calculates the result of vector subtraction.
VEC2Mult Calculates the product of two vectors.
VEC2Scale Calculates a scalar multiple of a vector.
VEC2LenSq Calculates the square of a vector length.
VEC2Len Calculates the vector length.
VEC3Normalize Normalizes a vector.
VEC3Add Calculates the resultant vector (the result of vector addition).
VEC3Sub Calculates the result of vector subtraction.
VEC3Mult Calculates the product of two vectors.
VEC3Scale Calculates a scalar multiple of a vector.
VEC3Lerp Calculates the linear interpolation between two vectors.
VEC3Dot Calculates the dot product of two vectors.
VEC3Len Calculates the vector length.
VEC3SquareLen Calculates the square of a vector length.
VEC3Dist Calculates the distance between two vectors.
Floating-Point Math Functions
U32AsF32 Converts a u32 type into an f32 type without changing the bit array.
FGetExpPart Gets the exponential part of a floating-point number.
FGetMantPart Finds the mantissa of a floating-point number.
FSelect Selects a value depending on the sign of the input.
FAbs Finds an absolute value.
FNAbs Finds the number whose sign is negative but whose absolute value is the same as the input.
FCopySign Copies the sign of one number to another number.
FExp Finds e^x.
FLog Finds the natural logarithm.
FLog10 Finds the common logarithm.
FMod Calculates the remainder.
FModf Breaks up a floating-point value into an integer part and a fractional part. The integer and fractional parts both have the same sign as x.
FCeil Finds the smallest integer value no smaller than x.
FFloor Finds the largest integer value no larger than x.
F32ToS16 Converts values in f32 format to s16 format.
F32ToU16 Converts values in f32 format to u16 format.
U16ToF32 Converts values in u16 format to f32 format.
S16ToF32 Converts values in s16 format to f32 format.
FInv Finds the multiplicative inverse at high speed and low precision.
FrSqrt Finds the inverse square root.
FSqrt Finds the square root.
FCbrt Finds the cube root.
Hermite Performs Hermite interpolation.
Integer Math Functions
CntLz Counts the number of consecutive bits set to 0, starting from the most significant bit (MSB).
IsPwr2 Determines whether an integer is a power of 2.
Rightmost1 Gets the rightmost bit (closest to the LSB) that is set to 1.
Rightmost0 Gets the rightmost bit (closest to the LSB) that is set to 0.
DistBit Calculates the hamming distance between two bit arrays.
CntTz Counts the number of consecutive bits set to 0, starting from the least significant bit (LSB).
ILog2 Calculates the base 2 logarithm of an integer and returns the result as an integer.
FloorPwr2 Calculates the highest power of 2 that is less than or equal to the integer provided.
CeilPwr2 Calculates the lowest power of 2 that is greater than or equal to the integer provided.
Trigonometric Functions
SinFIdx Finds the sine.
CosFIdx Finds the cosine.
SinCosFIdx Finds the sine and cosine.
TanFIdx Finds the tangent.
SinRad Finds the sine.
CosRad Finds the cosine.
SinCosRad Finds the sine and cosine.
TanRad Finds the tangent.
SinDeg Finds the sine.
CosDeg Finds the cosine.
SinCosDeg Finds the sine and cosine.
TanDeg Finds the tangent.
SinIdx Finds the sine.
CosIdx Finds the cosine.
SinCosIdx Finds the sine and cosine.
TanIdx Finds the tangent.
AsinFIdx Finds the inverse sine (arcsine).
AcosFIdx Finds the inverse cosine (arccosine).
AsinRad Finds the inverse sine (arcsine).
AcosRad Finds the inverse cosine (arccosine).
AtanRad Finds the inverse tangent (arctangent).
Atan2Rad Finds the inverse tangent (arctangent).
AsinDeg Finds the inverse sine (arcsine).
AcosDeg Finds the inverse cosine (arccosine).
AtanDeg Finds the inverse tangent (arctangent).
Atan2Deg Finds the inverse tangent (arctangent).
AsinIdx Finds the inverse sine (arcsine).
AcosIdx Finds the inverse cosine (arccosine).
AtanIdx Finds the inverse tangent (arctangent).
Atan2Idx Finds the inverse tangent (arctangent).
Math Functions
Abs Finds the absolute value.
Max Finds the maximum value.
Min Finds the minimum value.
Clamp Clamps a value to the specified range.
RoundUp Rounds a value up so it is a multiple of the specified value.
RoundDown Rounds a value down so it is a multiple of the specified value.
DivUp Finds the quotient of a division operation that takes two values. The remainder is rounded up.
ExtractBits Extracts the bit values from a specified range.
GetBits Gets the bit values from a specified range.
MakeBits Returns a 32-bit data value (bit array) after removing everything within that value but a specified range of bits.

Revision History

2010/01/07
Initial version.

CONFIDENTIAL