Functions
- operator*(v:V2f, m:M22f) -> V2f
- operator*(v:V3f, m:M33f) -> V3f
- operator*(v:V3f, m:M44f) -> V3f
- operator*(v:V4f, m:M44f) -> V4f
Vector-matrix multiplication: r = v * m
The V3f,M44f version is a point by matrix product.
- lerp(a, b, t)
Return a linear interpolation of a and b computed like this :
a * (1 - t) + b * t
- slerp(a: Quatf, b: Quatf, t: float) Quatf
Spherical linear interpolation. Assumes q1 and q2 are normalized and that q1 != -q2.
This method does not interpolate along the shortest arc between q1 and q2. If you desire interpolation along the shortest arc, and q1^q2 is negative, then consider calling slerpShortestArc(), below, or flipping the second quaternion explicitly.
- slerpShortestArc(a: Quatf, b: Quatf, t: float) Quatf
Spherical linear interpolation along the shortest arc from q1 to either q2 or -q2, whichever is closer. Assumes q1 and q2 are unit quaternions.
- spline(q0: Quatf, q1: Quatf, q2: Quatf, q3: Quatf, t: float) Quatf
Spherical Cubic Spline Interpolation - from Advanced Animation and Rendering Techniques by Watt and Watt, Page 366:
A spherical curve is constructed using three spherical linear interpolations of a quadrangle of unit quaternions: q1, qa, qb, q2. Given a set of quaternion keys: q0, q1, q2, q3, this routine does the interpolation between q1 and q2 by constructing two intermediate quaternions: qa and qb. The qa and qb are computed by the intermediate function to guarantee the continuity of tangents across adjacent cubic segments. The qa represents in-tangent for q1 and the qb represents the out-tangent for q2.
The q1 q2 is the cubic segment being interpolated.
The q0 is from the previous adjacent segment and q3 is from the next adjacent segment. The q0 and q3 are used in computing qa and qb.
- squad(q1: Quatf, qa: Quatf, qb: Quatf, q2: Quatf, t: float) Quatf
Spherical Quadrangle Interpolation - from Advanced Animation and Rendering Techniques by Watt and Watt, Page 366:
It constructs a spherical cubic interpolation as a series of three spherical linear interpolations of a quadrangle of unit quaternions.
- intermediate(q0: Quatf, q1: Quatf, q2: Quatf) Quatf
Compute the intermediate point between three quaternions q0, q1, and q2.
- extractScaling(mat: M44f, scl: V3f, exc: bool) bool
Extract the scaling component of the given 4x4 matrix.
[in] mat The input matrix
[out] scl The extracted scale, i.e. the output value
[out] exc If true, throw an exception if the scaling in mat is very close to zero.
Return True if the scale could be extracted, false if the matrix is degenerate.
- removeScaling(mat: M44f, exc: bool) bool
Remove scaling from the given 4x4 matrix in place. Return true if the scale could be successfully extracted, false if the matrix is degenerate.
[in,out] mat The matrix to operate on
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
Return True if the scale could be extracted, false if the matrix is degenerate.
- extractScalingAndShear(mat: M44f, scl: V3f, shr: V3f, exc: bool) bool
Extract the scaling and shear components of the given 4x4 matrix. Return true if the scale could be successfully extracted, false if the matrix is degenerate.
[in] mat The input matrix
[out] scl The extracted scale
[out] shr The extracted shear
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
Return True if the scale could be extracted, false if the matrix is degenerate.
- sansScalingAndShear(mat: M44f, scl: V3f, exc: bool) M44f
Return the given 4x4 matrix with scaling and shear removed.
[in] mat The input matrix
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
- sansScalingAndShear(result: M44f, mat: M44f, scl: V3f, exc: bool) M44f
Extract scaling and shear from the given 4x4 matrix in-place.
[in,out] result The output matrix
[in] mat The return value if result is degenerate
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
- removeScalingAndShear(mat: M44f, scl: V3f, exc: bool) bool
Remove scaling and shear from the given 4x4 matrix in place.
[in,out] mat The matrix to operate on
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
Return True if the scale could be extracted, false if the matrix is degenerate.
- extractAndRemoveScalingAndShear(mat: M44f, scl: V3f, shr: V3f, exc: bool) bool
Remove scaling and shear from the given 4x4 matrix in place, returning the extracted values.
[in,out] mat The matrix to operate on
[out] scl The extracted scale
[out] shr The extracted shear
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
Return True if the scale could be extracted, false if the matrix is degenerate.
- extractEulerXYZ(mat: M44f, rot: V3f)
Extract the rotation from the given 4x4 matrix in the form of XYZ euler angles.
[in] mat The input matrix
[out] rot The extracted XYZ euler angle vector
- extractEulerZYX(mat: M44f, rot: V3f)
Extract the rotation from the given 4x4 matrix in the form of ZYX euler angles.
[in] mat The input matrix
[out] rot The extracted ZYX euler angle vector
- extractQuat(mat: M44f) Quatf
Extract the rotation from the given 4x4 matrix in the form of a quaternion.
[in] mat The input matrix
Return The extracted quaternion
- extractSHRT(mat:M44f, s:V3f, h:V3f, r:V3f, t:V3f, bool, Eulerf.Order order) bool
Extract the scaling, shear, rotation, and translation components of the given 4x4 matrix. The values are such that:
M = S * H * R * T
[in] mat The input matrix
[out] s The extracted scale
[out] h The extracted shear
[out] r The extracted rotation
[out] t The extracted translation
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
[in] rOrder The order with which to extract the rotation
Return True if the values could be extracted, false if the matrix is degenerate.
- rotationMatrix(fromDirection: V3f, toDirection: V3f) M44f
Return a 4x4 matrix that rotates the vector fromDirection to toDirection
- rotationMatrixWithUpDir(fromDir: V3f, toDir: V3f, upDir: V3f) M44f
Return a 4x4 matrix that rotates the fromDir vector so that it points towards toDir1. You may also specify that you want the up vector to be pointing in a certain direction upDir.
- alignZAxisWithTargetDir(result: M44f, targetDir: V3f, upDir: V3f)
Construct a 4x4 matrix that rotates the z-axis so that it points towards targetDir. You must also specify that you want the up vector to be pointing in a certain direction upDir.
Notes: The following degenerate cases are handled: (a) when the directions given by toDir and upDir are parallel or opposite (the direction vectors must have a non-zero cross product); (b) when any of the given direction vectors have zero length
[out] result The output matrix
[in] targetDir The target direction vector
[in] upDir The up direction vector
- computeLocalFrame(p: V3f, xDir: V3f, normal: V3f) M44f
Compute an orthonormal direct 4x4 frame from a position, an x axis direction and a normal to the y axis. If the x axis and normal are perpendicular, then the normal will have the same direction as the z axis.
[in] p The position of the frame
[in] xDir The x axis direction of the frame
[in] normal A normal to the y axis of the frame
Return The orthonormal frame
- addOffset(inMat: M44f, tOffset: V3f, rOffset: V3f, sOffset: V3f, ref: V3f) M44f
Add a translate/rotate/scale offset to a 4x4 input frame and put it in another frame of reference
[in] inMat Input frame
[in] tOffset Translation offset
[in] rOffset Rotation offset in degrees
[in] sOffset Scale offset
[in] ref Frame of reference
Return The offsetted frame
- computeRSMatrix(keepRotateA: bool, keepScaleA: bool, A: M44f, B: M44f) M44f
Compute 4x4 translate/rotate/scale matrix from A with the rotate/scale of B.
[in] keepRotateA If true, keep rotate from matrix A, use B otherwise
[in] keepScaleA If true, keep scale from matrix A, use B otherwise
[in] A Matrix A
[in] B Matrix B
Return Matrix A with tweaked rotation/scale
- extractScaling(mat: M33f, scl: V2f, exc: bool) bool
Extract the scaling component of the given 3x3 matrix.
[in] mat The input matrix
[out] scl The extracted scale, i.e. the output value
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
Return True if the scale could be extracted, false if the matrix is degenerate.
- sansScaling(mat: M33f, exc: bool) M33f
Return the given 3x3 matrix with scaling removed.
[in] mat The input matrix
[in] exc If true, throw an exception if the scaling in mat
- sansScalingAndShear(mat: M33f, exc: bool) M33f
Return the given 3x3 matrix with scaling and shear removed.
[in] mat The input matrix
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
- removeScaling(mat: M33f, exc: bool) bool
Remove scaling from the given 3x3 matrix in place. Return true if the scale could be successfully extracted, false if the matrix is degenerate.
[in] mat The matrix to operate on
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
Return True if the scale could be extracted, false if the matrix is degenerate.
- removeScalingAndShear(mat: M33f, exc: bool) bool
Remove scaling and shear from the given 3x3 matrix in place.
[in,out] mat The matrix to operate on
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
Return True if the scale could be extracted, false if the matrix is degenerate.
- extractScalingAndShear(mat: M33f, scl: V2f, shr: float, exc: bool) bool
Extract the scaling and shear components of the given 3x3 matrix. Return true if the scale could be successfully extracted, false if the matrix is degenerate.
[in] mat The input matrix
[out] scl The extracted scale
[out] shr The extracted shear
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
Return True if the scale could be extracted, false if the matrix is degenerate.
- extractAndRemoveScalingAndShear(mat: M33f, scl: V2f, shr: float, exc: bool) bool
Remove scaling and shear from the given 3x3 matrix in place, returning the extracted values.
[in,out] mat The matrix to operate on
[out] scl The extracted scale
[out] shr The extracted shear
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
Return True if the scale could be extracted, false if the matrix is degenerate.
- extractEuler(mat: M22f, rot: float)
Extract the rotation from the given 2x2 matrix
[in] mat The input matrix
[out] rot The extracted rotation value
- extractEuler(mat: M33f, rot: float)
Extract the rotation from the given 3x3 matrix
[in] mat The input matrix
[out] rot The extracted rotation value
- extractSHRT(mat: M33f, s: V2f, h: float, r: float, t: V2f, exc: bool) bool
Extract the scaling, shear, rotation, and translation components of the given 3x3 matrix. The values are such that:
M = S * H * R * T
[in] mat The input matrix
[out] s The extracted scale
[out] h The extracted shear
[out] r The extracted rotation
[out] t The extracted translation
[in] exc If true, throw an exception if the scaling in mat is very close to zero.
Return True if the values could be extracted, false if the matrix is degenerate.
- checkForZeroScaleInRow(scl: float, row: V2f, exc: bool) bool
Return true if the given scale can be removed from the given row matrix, false if scl is small enough that the operation would overflow. If exc is true, throw an exception on overflow.
- equalWithAbsError(x1, x2, e):
Compare two numbers and test if they are “approximately equal”: Return True if x1 is the same as x2 with an absolute error of no more than e:
abs (x1 - x2) <= e
- equalWithRelError(x1, x2, e):
Compare two numbers and test if they are “approximately equal”: Return True if x1 is the same as x2 with an relative error of no more than e,
abs (x1 - x2) <= e * x1