Class B3Math
- Namespace
- Box3D.Native
- Assembly
- Box3D.NET.Native.dll
The Box3D math helpers that are not exported from the native library.
public static class B3MathInheritance
Inherited Members
Remarks
Most of the functions in math_functions.h are declared
B3_INLINE, which expands to static inline. They have internal
linkage in every translation unit and are therefore absent from the shared
library's export table: they cannot be bound with a P/Invoke and are
reimplemented here instead.
The implementations follow the C source operation by operation rather than
delegating to System.Numerics. Box3D guarantees cross-platform
determinism, and floating point addition is not associative, so reordering
the terms of a dot product or a normalization can change the last bit of the
result. Where Box3D calls its own deterministic b3Atan2 or
b3ComputeCosSin, this code calls into the native library for the same
reason.
Fields
- FltEpsilon
-
The difference between one and the next representable System.Single, equivalent to C's
FLT_EPSILON. - FltMin
-
The smallest normalized positive System.Single, equivalent to C's
FLT_MIN.
Methods
- b3AABB_Area(b3AABB)
-
Computes the surface area of a box.
- b3AABB_Center(b3AABB)
-
Computes the centre of a box.
- b3AABB_Contains(b3AABB, b3AABB)
-
Determines whether one box fully contains another.
- b3AABB_Extents(b3AABB)
-
Computes the half-widths of a box.
- b3AABB_Inflate(b3AABB, float)
-
Expands a box uniformly.
- b3AABB_Overlaps(b3AABB, b3AABB)
-
Determines whether two boxes overlap.
- b3AABB_Transform(b3Transform, b3AABB)
-
Transforms a bounding box.
- b3AABB_Union(b3AABB, b3AABB)
-
Computes the smallest box containing two boxes.
- b3Abs(Vector3)
-
Computes the component-wise absolute value of a vector.
- b3AbsFloat(float)
-
Returns the absolute value of a number.
- b3AbsMatrix3(b3Matrix3)
-
Computes the component-wise absolute value of a matrix.
- b3Add(Vector3, Vector3)
-
Adds two vectors.
- b3AddMM(b3Matrix3, b3Matrix3)
-
Adds two matrices.
- b3Blend2(float, Vector3, float, Vector3)
-
Computes
s * a + t * b. - b3Clamp(Vector3, Vector3, Vector3)
-
Clamps a vector component-wise to a range.
- b3ClampFloat(float, float, float)
-
Clamps a number to a range.
- b3ClampInt(int, int, int)
-
Clamps an integer to a range.
- b3ClosestPointToAABB(Vector3, b3AABB)
-
Computes the closest point on a box to a point.
- b3Conjugate(Quaternion)
-
Computes the conjugate of a quaternion, which is a cheap inverse for unit quaternions.
- b3Cos(float)
-
Computes the cosine of an angle.
- b3Cross(Vector3, Vector3)
-
Computes the cross product of two vectors.
- b3Det(b3Matrix3)
-
Computes the determinant of a matrix.
- b3Distance(Vector3, Vector3)
-
Computes the distance between two points.
- b3DistanceSquared(Vector3, Vector3)
-
Computes the squared distance between two points.
- b3Dot(Vector3, Vector3)
-
Computes the dot product of two vectors.
- b3DotQuat(Quaternion, Quaternion)
-
Computes the dot product of two quaternions, which is useful for polarity tests.
- b3GetAxisAngle(out float, Quaternion)
-
Extracts the axis and angle of a rotation.
- b3GetLengthAndNormalize(out float, Vector3)
-
Normalizes a vector and reports its original length.
- b3GetQuatAngle(Quaternion)
-
Gets the rotation angle of a quaternion.
- b3GetSwingAngle(Quaternion)
-
Gets the swing angle away from the z axis, used by cone limits.
- b3GetTwistAngle(Quaternion)
-
Gets the twist angle about the z axis, used by twist limits and the revolute joint angle limit.
- b3InvMulQuat(Quaternion, Quaternion)
-
Computes the relative rotation
inv(q1) * q2. - b3InvMulTransforms(b3Transform, b3Transform)
-
Builds the transform that converts a point local to frame B into a point local to frame A.
- b3InvMulWorldTransforms(b3Transform, b3Transform)
-
Computes the pose of world frame B relative to world frame A.
- b3InvRotateVector(Quaternion, Vector3)
-
Rotates a vector by the inverse of a quaternion.
- b3InvTransformPoint(b3Transform, Vector3)
-
Applies the inverse of a transform to a point.
- b3InvTransformWorldPoint(b3Transform, Vector3)
-
Transforms a world position into a local point.
- b3InvertMatrix(b3Matrix3)
-
Inverts a matrix.
- b3InvertT(b3Matrix3)
-
Computes the inverse transpose of a matrix.
- b3InvertTransform(b3Transform)
-
Inverts a transform.
- b3IsNormalized(Vector3)
-
Determines whether a vector has unit length.
- b3IsNormalizedQuat(Quaternion)
-
Determines whether a quaternion has unit length.
- b3Length(Vector3)
-
Computes the length of a vector.
- b3LengthSquared(Vector3)
-
Computes the squared length of a vector.
- b3Lerp(Vector3, Vector3, float)
-
Linearly interpolates between two vectors.
- b3LerpFloat(float, float, float)
-
Linearly interpolates between two numbers.
- b3LerpPosition(Vector3, Vector3, float)
-
Interpolates between two world positions.
- b3MakeAABB(ReadOnlySpan<Vector3>, float)
-
Computes the bounding box of a point cloud.
- b3MakeMatrixFromQuat(Quaternion)
-
Builds a rotation matrix from a quaternion.
- b3MakeQuatFromAxisAngle(Vector3, float)
-
Builds a rotation about an axis.
- b3MakeWorldTransform(b3Transform)
-
Promotes a local transform to a world transform.
- b3Max(Vector3, Vector3)
-
Computes the component-wise maximum of two vectors.
- b3MaxFloat(float, float)
-
Returns the larger of two numbers.
- b3MaxInt(int, int)
-
Returns the larger of two integers.
- b3Min(Vector3, Vector3)
-
Computes the component-wise minimum of two vectors.
- b3MinFloat(float, float)
-
Returns the smaller of two numbers.
- b3MinInt(int, int)
-
Returns the smaller of two integers.
- b3Mul(Vector3, Vector3)
-
Multiplies two vectors component-wise.
- b3MulAdd(Vector3, float, Vector3)
-
Computes
a + s * b. - b3MulMM(b3Matrix3, b3Matrix3)
-
Multiplies two matrices.
- b3MulMV(b3Matrix3, Vector3)
-
Multiplies a matrix by a column vector.
- b3MulQuat(Quaternion, Quaternion)
-
Multiplies two quaternions.
- b3MulSM(float, b3Matrix3)
-
Scales a matrix.
- b3MulSV(float, Vector3)
-
Scales a vector.
- b3MulSub(Vector3, float, Vector3)
-
Computes
a - s * b. - b3MulTransforms(b3Transform, b3Transform)
-
Composes two transforms, so that the result maps a point in frame B into the frame that
amaps into. - b3MulWorldTransforms(b3Transform, b3Transform)
-
Composes a world transform with a local transform.
- b3NLerp(Quaternion, Quaternion, float)
-
Interpolates between two rotations and normalizes the result.
- b3Neg(Vector3)
-
Negates a vector.
- b3NegateMat3(b3Matrix3)
-
Negates a matrix.
- b3NegateQuat(Quaternion)
-
Negates every component of a quaternion.
- b3Normalize(Vector3)
-
Normalizes a vector.
- b3NormalizeQuat(Quaternion)
-
Normalizes a quaternion.
- b3OffsetAABB(b3AABB, Vector3)
-
Translates a local box by a world origin.
- b3OffsetPos(Vector3, Vector3)
-
Offsets a world position by a vector.
- b3Perp(Vector3)
-
Computes a unit vector perpendicular to the given vector.
- b3RotateVector(Quaternion, Vector3)
-
Rotates a vector by a quaternion.
- b3RoundDownFloat(double)
-
Narrows a world coordinate towards negative infinity.
- b3RoundUpFloat(double)
-
Narrows a world coordinate towards positive infinity.
- b3SafeScale(Vector3)
-
Makes a scale value safe for scaling collision geometry.
- b3Sign(Vector3)
-
Computes the component-wise sign of a vector, treating zero as positive.
- b3Sin(float)
-
Computes the sine of an angle.
- b3Solve3(b3Matrix3, Vector3)
-
Solves
m * x = afor x. - b3Sub(Vector3, Vector3)
-
Subtracts one vector from another.
- b3SubMM(b3Matrix3, b3Matrix3)
-
Subtracts one matrix from another.
- b3SubPos(Vector3, Vector3)
-
Subtracts two world positions, producing a local offset.
- b3ToPos(Vector3)
-
Converts a vector to a world position.
- b3ToRelativeTransform(b3Transform, Vector3)
-
Shifts a world transform into the frame of a base position.
- b3ToVec3(Vector3)
-
Converts a world position to a vector.
- b3TransformPoint(b3Transform, Vector3)
-
Applies a transform to a point.
- b3TransformWorldPoint(b3Transform, Vector3)
-
Transforms a local point into a world position.
- b3Transpose(b3Matrix3)
-
Transposes a matrix.
- b3UnwindAngle(float)
-
Wraps an angle into the range minus pi to pi.