Class MathHelper
- Namespace
- Jitter2.LinearMath
- Assembly
- Jitter2.dll
Provides mathematical helper methods for linear algebra and physics calculations.
public static class MathHelper
- Inheritance
-
MathHelper
- Inherited Members
Methods
CheckOrthonormalBasis(in JMatrix, float)
Verifies whether the columns of the given matrix constitute an orthonormal basis.
public static bool CheckOrthonormalBasis(in JMatrix matrix, float epsilon = 1E-06)
Parameters
matrixJMatrixThe input matrix to check.
epsilonfloatThe tolerance for floating-point comparisons.
Returns
CloseToZero(in JVector, float)
Determines whether the length of the given vector is zero or close to zero.
public static bool CloseToZero(in JVector v, float epsilonSq = 1E-16)
Parameters
Returns
CreateOrthonormal(in JVector)
Calculates an orthonormal vector to the given vector.
public static JVector CreateOrthonormal(in JVector vec)
Parameters
vecJVectorThe input vector (must be non-zero, does not need to be normalized).
Returns
- JVector
A unit vector orthogonal to the input.
Remarks
The input vector must be non-zero. Debug builds assert this condition.
InverseSquareRoot(JMatrix, int)
Calculates (MᵀM)^(-1/2) using Jacobi iterations.
public static JMatrix InverseSquareRoot(JMatrix m, int sweeps = 2)
Parameters
Returns
- JMatrix
The inverse square root of
MᵀM.
IsRotationMatrix(in JMatrix, float)
Checks if matrix is a pure rotation matrix.
public static bool IsRotationMatrix(in JMatrix matrix, float epsilon = 1E-06)
Parameters
Returns
IsZero(in JVector, float)
Checks if all entries of a vector are close to zero.
public static bool IsZero(in JVector vector, float epsilon = 1E-06)
Parameters
Returns
IsZero(float, float)
Checks if a value is close to zero.
public static bool IsZero(float value, float epsilon = 1E-06)
Parameters
Returns
RotationQuaternion(in JVector, float)
Calculates the rotation quaternion corresponding to the given (constant) angular velocity vector and time step.
public static JQuaternion RotationQuaternion(in JVector omega, float dt)
Parameters
Returns
- JQuaternion
A unit quaternion representing the rotation.
SignBit(double)
Gets the sign of value purely from its IEEE-754 sign bit.
public static int SignBit(double value)
Parameters
valuedoubleThe number to test.
Returns
- int
+1when the sign bit is clear (positive, +0, or a positive-sign NaN),-1when the sign bit is set (negative, −0, or a negative-sign NaN). Never returns0, unlike Sign(float).
SignBit(float)
Gets the sign of value purely from its IEEE-754 sign bit.
public static int SignBit(float value)
Parameters
valuefloatThe number to test.
Returns
- int
+1when the sign bit is clear (positive, +0, or a positive-sign NaN),-1when the sign bit is set (negative, −0, or a negative-sign NaN). Never returns0, unlike Sign(float).
UnsafeIsZero(ref JMatrix, float)
Checks if all entries of a matrix are close to zero.
public static bool UnsafeIsZero(ref JMatrix matrix, float epsilon = 1E-06)