Class BurstMathUtility
Provides utility functions related to vector and quaternion calculations, optimized for use with the Burst compiler when available.
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit.Utilities
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
public static class BurstMathUtility
Methods
Angle(in quaternion, in quaternion, out float)
Returns the angle in degrees between two rotations a
and b
.
Equivalent to Angle.
Declaration
public static void Angle(in quaternion a, in quaternion b, out float angle)
Parameters
Type | Name | Description |
---|---|---|
quaternion | a | The first rotation in the quaternion set. |
quaternion | b | The second rotation in the quaternion set. |
float | angle | The angle in degrees between a and b. |
FastSafeDivide(in float3, in float3, out float3, float)
Performs a safe division of two float3 vectors. If the difference between any corresponding pair of components in the vectors exceeds a specified tolerance, the division is carried out for that component.
Declaration
public static void FastSafeDivide(in float3 a, in float3 b, out float3 result, float tolerance = 1E-06)
Parameters
Type | Name | Description |
---|---|---|
float3 | a | The dividend float3 vector. |
float3 | b | The divisor float3 vector. |
float3 | result | The resulting float3 vector after division. If the difference between the corresponding components of the dividend and divisor is less than the tolerance, the respective component in the result vector remains zero. |
float | tolerance | The tolerance for the component-wise division operation. Defaults to 0.000001f. |
FastSafeDivide(in Vector3, in Vector3, out Vector3, float)
Performs a safe division of two Vector3s. If the difference between any corresponding pair of components in the vectors exceeds a specified tolerance, the division is carried out for that component.
Declaration
public static void FastSafeDivide(in Vector3 a, in Vector3 b, out Vector3 result, float tolerance = 1E-06)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | a | The dividend Vector3. |
Vector3 | b | The divisor Vector3. |
Vector3 | result | The resulting Vector3 after division. If the difference between the corresponding components of the dividend and divisor is less than the tolerance, the respective component in the result vector remains zero. |
float | tolerance | The tolerance for the component-wise division operation. Defaults to 0.000001f. |
FastVectorEquals(in float3, in float3, float)
Compares two float3s for equality with a specified level of tolerance.
Declaration
public static bool FastVectorEquals(in float3 a, in float3 b, float tolerance = 0.0001)
Parameters
Type | Name | Description |
---|---|---|
float3 | a | The first float3 to compare. |
float3 | b | The second float3 to compare. |
float | tolerance | The level of tolerance for the equality check. Defaults to 0.0001f. |
Returns
Type | Description |
---|---|
bool | Returns true if the difference between the corresponding components of the float3s is less than the specified tolerance; otherwise, false. |
FastVectorEquals(in Vector3, in Vector3, float)
Compares two Vector3s for equality with a specified level of tolerance.
Declaration
public static bool FastVectorEquals(in Vector3 a, in Vector3 b, float tolerance = 0.0001)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | a | The first Vector3 to compare. |
Vector3 | b | The second Vector3 to compare. |
float | tolerance | The level of tolerance for the equality check. Defaults to 0.0001f. |
Returns
Type | Description |
---|---|
bool | Returns true if the difference between the corresponding components of the Vector3s is less than the specified tolerance; otherwise, false. |
LookRotationWithForwardProjectedOnPlane(in float3, in float3, out quaternion)
Computes the look rotation with the forward vector projected on a plane defined by a normal orthogonal to the plane.
Declaration
public static void LookRotationWithForwardProjectedOnPlane(in float3 forward, in float3 planeNormal, out quaternion lookRotation)
Parameters
Type | Name | Description |
---|---|---|
float3 | forward | The forward vector to be projected onto the plane. |
float3 | planeNormal | The normal vector orthogonal to the plane. |
quaternion | lookRotation | The resulting look rotation with the projected forward vector and plane normal as up direction. |
LookRotationWithForwardProjectedOnPlane(in Vector3, in Vector3, out Quaternion)
Computes the look rotation with the forward vector projected on a plane defined by a normal orthogonal to the plane.
Declaration
public static void LookRotationWithForwardProjectedOnPlane(in Vector3 forward, in Vector3 planeNormal, out Quaternion lookRotation)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | forward | The forward vector to be projected onto the plane. |
Vector3 | planeNormal | The normal vector orthogonal to the plane. |
Quaternion | lookRotation | The resulting look rotation with the projected forward vector and plane normal as up direction. |
Remarks
Convenience method signature to cast output from Unity.Mathematics.quaternion to Quaternion.
OrthogonalLookRotation(in float3, in float3, out quaternion)
Calculates a look rotation quaternion given a forward vector and a reference up vector.
Declaration
public static void OrthogonalLookRotation(in float3 forward, in float3 referenceUp, out quaternion lookRotation)
Parameters
Type | Name | Description |
---|---|---|
float3 | forward | The forward vector. |
float3 | referenceUp | The reference up vector. |
quaternion | lookRotation | The calculated look rotation quaternion. |
OrthogonalLookRotation(in Vector3, in Vector3, out Quaternion)
Calculates a look rotation quaternion given a forward vector and a reference up vector.
Declaration
public static void OrthogonalLookRotation(in Vector3 forward, in Vector3 referenceUp, out Quaternion lookRotation)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | forward | The forward vector. |
Vector3 | referenceUp | The reference up vector. |
Quaternion | lookRotation | The calculated look rotation quaternion. |
Remarks
Convenience method signature to cast output from Unity.Mathematics.quaternion to Quaternion.
OrthogonalUpVector(in float3, in float3, out float3)
Calculates the orthogonal up vector for a given forward vector and a reference up vector.
Declaration
public static void OrthogonalUpVector(in float3 forward, in float3 referenceUp, out float3 orthogonalUp)
Parameters
Type | Name | Description |
---|---|---|
float3 | forward | The forward vector. |
float3 | referenceUp | The reference up vector. |
float3 | orthogonalUp | The calculated orthogonal up vector. |
OrthogonalUpVector(in Vector3, in Vector3, out Vector3)
Calculates the orthogonal up vector for a given forward vector and a reference up vector.
Declaration
public static void OrthogonalUpVector(in Vector3 forward, in Vector3 referenceUp, out Vector3 orthogonalUp)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | forward | The forward vector. |
Vector3 | referenceUp | The reference up vector. |
Vector3 | orthogonalUp | The calculated orthogonal up vector. |
Remarks
Convenience method signature to cast output from Unity.Mathematics.float3 to Vector3.
ProjectOnPlane(in float3, in float3, out float3)
Projects a vector onto a plane defined by a normal orthogonal to the plane.
Declaration
public static void ProjectOnPlane(in float3 vector, in float3 planeNormal, out float3 projectedVector)
Parameters
Type | Name | Description |
---|---|---|
float3 | vector | The vector to be projected. |
float3 | planeNormal | The normal vector orthogonal to the plane. |
float3 | projectedVector | The projected vector on the plane. |
ProjectOnPlane(in Vector3, in Vector3, out Vector3)
Projects a vector onto a plane defined by a normal orthogonal to the plane.
Declaration
public static void ProjectOnPlane(in Vector3 vector, in Vector3 planeNormal, out Vector3 projectedVector)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector | The vector to be projected. |
Vector3 | planeNormal | The normal vector orthogonal to the plane. |
Vector3 | projectedVector | The projected vector on the plane. |
Remarks
Convenience method signature to cast output from Unity.Mathematics.float3 to Vector3.
Scale(in float3, in float3, out float3)
Multiplies the corresponding elements of two float3 vectors in a fast, non-matrix multiplication.
Declaration
public static void Scale(in float3 a, in float3 b, out float3 result)
Parameters
Type | Name | Description |
---|---|---|
float3 | a | The first float3 vector. |
float3 | b | The second float3 vector. |
float3 | result | The resulting float3 vector after element-wise multiplication. |
Scale(in Vector3, in Vector3, out Vector3)
Multiplies the corresponding elements of two Vector3 in a fast, non-matrix multiplication.
Declaration
public static void Scale(in Vector3 a, in Vector3 b, out Vector3 result)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | a | The first Vector3. |
Vector3 | b | The second Vector3. |
Vector3 | result | The resulting Vector3 after element-wise multiplication. |