Class TransformMath
Namespace: ValveResourceFormat.Animation
Assembly: ValveResourceFormat.dll
Transform helpers that have no equivalent on FrameBone itself.
public static class TransformMathInheritance
object ← TransformMath
Fields
Epsilon
The default tolerance for near comparisons.
public const float Epsilon = 1E-06Field Value
float
WorldForward
The world forward axis.
public static readonly Vector3 WorldForwardField Value
WorldLeft
The world left axis.
public static readonly Vector3 WorldLeftField Value
WorldRight
The world right axis.
public static readonly Vector3 WorldRightField Value
WorldUp
The world up axis.
public static readonly Vector3 WorldUpField Value
Properties
Zero
The identity additive transform.
public static FrameBone Zero { get; }Property Value
Methods
CalculateAngleBetweenVectorsAroundAnAxis(Vector3, Vector3, Vector3)
The signed angle between two vectors around an axis.
public static float CalculateAngleBetweenVectorsAroundAnAxis(Vector3 sourceVector, Vector3 targetVector, Vector3 rotationAxis)Parameters
sourceVector Vector3
targetVector Vector3
rotationAxis Vector3
Returns
float
Delta(FrameBone, FrameBone)
The delta that concatenated onto from gives to.
public static FrameBone Delta(FrameBone from, FrameBone to)Parameters
from FrameBone
to FrameBone
Returns
DeltaNoScale(FrameBone, FrameBone)
The delta that concatenated onto from gives to, ignoring scale.
public static FrameBone DeltaNoScale(FrameBone from, FrameBone to)Parameters
from FrameBone
to FrameBone
Returns
FastSLerp(Quaternion, Quaternion, float)
An approximated spherical interpolation, renormalized.
public static Quaternion FastSLerp(Quaternion q0, Quaternion q1, float t)Parameters
q0 Quaternion
q1 Quaternion
t float
Returns
Remarks
A linear interpolation whose time is corrected by a polynomial fitted to the spherical one, from Jonathan Blow, "Hacking Quaternions", The Inner Product, March 2002.
FromRotationBetweenUnitVectors(Vector3, Vector3)
The shortest rotation aligning one unit vector onto another.
public static Quaternion FromRotationBetweenUnitVectors(Vector3 from, Vector3 to)Parameters
from Vector3
to Vector3
Returns
FromRotationBetweenUnitVectors(Vector3, Vector3, Vector3)
The rotation aligning one unit vector onto another, around a fallback axis for opposite vectors.
public static Quaternion FromRotationBetweenUnitVectors(Vector3 from, Vector3 to, Vector3 fallbackRotationAxis)Parameters
from Vector3
to Vector3
fallbackRotationAxis Vector3
Returns
GetAngle(Quaternion)
The rotation angle of a quaternion in radians, in [0, 2pi].
public static float GetAngle(Quaternion q)Parameters
Returns
float
InverseRotateVector(Quaternion, Vector3)
Rotates a vector by the inverse of a rotation.
public static Vector3 InverseRotateVector(Quaternion q, Vector3 v)Parameters
v Vector3
Returns
IsNearEqual(FrameBone, FrameBone, float, float)
Whether two transforms are equal within an angle and a translation and scale tolerance.
public static bool IsNearEqual(FrameBone a, FrameBone b, float angleThreshold = 0.017453292, float translationScaleThreshold = 1E-06)Parameters
angleThreshold float
translationScaleThreshold float
Returns
bool
IsNearZero(Vector3, float)
Whether every component of a vector is within epsilon of zero.
public static bool IsNearZero(Vector3 v, float epsilon = 1E-06)Parameters
v Vector3
epsilon float
Returns
bool
IsNearZero2(Vector3, float)
Whether the ground plane components are within epsilon of zero.
public static bool IsNearZero2(Vector3 v, float epsilon = 1E-06)Parameters
v Vector3
epsilon float
Returns
bool
IsVectorInTheSameHemisphere2D(Vector3, Vector3)
Whether two vectors point the same way on the ground plane.
public static bool IsVectorInTheSameHemisphere2D(Vector3 reference, Vector3 v)Parameters
reference Vector3
v Vector3
Returns
bool
Length2(Vector3)
The length on the ground plane, ignoring the vertical component.
public static float Length2(Vector3 v)Parameters
v Vector3
Returns
float
Lerp(FrameBone, FrameBone, float)
Interpolates translation and scale linearly and rotation with a normalized lerp.
public static FrameBone Lerp(FrameBone from, FrameBone to, float t)Parameters
from FrameBone
to FrameBone
t float
Returns
LookAt(Vector3, Vector3)
A rotation facing the forward vector while keeping as close to the up vector as possible.
public static Quaternion LookAt(Vector3 forwardVector, Vector3 upVector)Parameters
forwardVector Vector3
upVector Vector3
Returns
NLerp(Quaternion, Quaternion, float)
Normalized linear interpolation, taking the shorter path.
public static Quaternion NLerp(Quaternion from, Quaternion to, float t)Parameters
from Quaternion
to Quaternion
t float
Returns
Normalize2(Vector3)
Normalizes on the ground plane, dropping the vertical component.
public static Vector3 Normalize2(Vector3 v)Parameters
v Vector3
Returns
RotateVector(Quaternion, Vector3)
Rotates a vector by a rotation.
public static Vector3 RotateVector(Quaternion q, Vector3 v)Parameters
v Vector3
Returns
SLerp(FrameBone, FrameBone, float)
Interpolates translation and scale linearly and rotation spherically.
public static FrameBone SLerp(FrameBone from, FrameBone to, float t)Parameters
from FrameBone
to FrameBone
t float
Returns
ToEulerAngles(Quaternion)
Rotations around the X, Y and Z axes in radians, decomposed from the rotation matrix.
public static Vector3 ToEulerAngles(Quaternion q)
