docs.unity3d.com
  • Manual
  • Scripting API
  • Changelog
  • License

    • Unity.Geospatial.HighPrecision
      • DoubleBounds
      • DoublePlane
      • HPMath
      • HPNode
      • HPNode.ScaleTypes
      • HPRoot
      • HPTransform
      • LocalCoordinateSystem
      • MathExtension
      • MatrixExtension
      • SerializableDoubleBounds
    • Unity.Geospatial.HighPrecision.Editor
      • CoordinateSystemInspector
      • CoordinateSystemInspector.ScaleTypes
      • DefaultCoordinateSystemInspector
      • EditorGUILayoutWrapper
      • HPNodeInspector
      • HPRootInspector
      • HPTransformInspector
      • TransformEditorOverride

    Class HPMath

    Mathematics methods used for easily converting data between geodetic formats and Unity default expected formats.

    Inheritance
    Object
    HPMath
    Namespace: Unity.Geospatial.HighPrecision
    Assembly: solution.dll
    Syntax
    [BurstCompile(CompileSynchronously = true)]
    public static class HPMath

    Methods

    AxisAngleDegrees(float3, Single)

    Returns a quaternion representing a rotation around a unit axis by an angle in degrees. The rotation direction is clockwise when looking along the rotation axis towards the origin.

    Declaration
    public static quaternion AxisAngleDegrees(float3 axis, float angle)
    Parameters
    Type Name Description
    float3 axis

    The axis of rotation.

    Single angle

    The angle of rotation in degrees.

    Returns
    Type Description
    quaternion

    The quaternion representing a rotation around an axis.

    EulerZXYDegrees(float3)

    Returns a quaternion constructed by first performing a rotation around the z-axis, then the x-axis and finally the y-axis. All rotation angles are in degrees and clockwise when looking along the rotation axis towards the origin. This is the default order rotation order in Unity.

    Declaration
    public static quaternion EulerZXYDegrees(float3 xyz)
    Parameters
    Type Name Description
    float3 xyz

    A float3 vector containing the rotation angles around the x-, y- and z-axis measures in degrees.

    Returns
    Type Description
    quaternion

    The quaternion representing the Euler angle rotation in z-x-y order.

    GetEulerDegrees(quaternion)

    Returns the Euler angle representation of the quaternion following the ZYX rotation order. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.

    Declaration
    public static float3 GetEulerDegrees(this quaternion rotation)
    Parameters
    Type Name Description
    quaternion rotation

    The quaternion to convert to Euler angles.

    Returns
    Type Description
    float3

    The Euler angle representation of the quaternion in ZYX order.

    GetEulerZXY(quaternion)

    Returns the Euler angle representation of the quaternion following the ZYX rotation order. All rotation angles are in radians and clockwise when looking along the rotation axis towards the origin.

    Declaration
    public static float3 GetEulerZXY(this quaternion rotation)
    Parameters
    Type Name Description
    quaternion rotation

    The quaternion to convert to Euler angles.

    Returns
    Type Description
    float3

    The Euler angle representation of the quaternion in ZYX order.

    GetRotation(double4x4)

    Get the rotation part of a matrix as a quaternion expressed in radians.

    Declaration
    public static quaternion GetRotation(this double4x4 matrix)
    Parameters
    Type Name Description
    double4x4 matrix

    Matrix to extract the rotation from.

    Returns
    Type Description
    quaternion

    The rotation result.

    GetScale(double4x4)

    Get the scaling part of a matrix.

    Declaration
    public static float3 GetScale(this double4x4 matrix)
    Parameters
    Type Name Description
    double4x4 matrix

    Matrix to extract the scaling from.

    Returns
    Type Description
    float3

    The scaling result.

    GetTranslation(double4x4)

    Get the position part of a matrix.

    Declaration
    public static double3 GetTranslation(this double4x4 matrix)
    Parameters
    Type Name Description
    double4x4 matrix

    Matrix to extract the position from.

    Returns
    Type Description
    double3

    The position result.

    GetTRS(double4x4, out double3, out quaternion, out float3)

    Get the translation, rotation and scale part of the given matrix.

    Declaration
    public static void GetTRS(this double4x4 matrix, out double3 translation, out quaternion rotation, out float3 scale)
    Parameters
    Type Name Description
    double4x4 matrix

    The matrix requested to get its translation, rotation and scale from.

    double3 translation

    Returns the position part.

    quaternion rotation

    Returns the orientation part.

    float3 scale

    Returns the resize part.

    Translate(double3)

    Returns a double4x4 translation matrix given a double3 translation vector.

    Declaration
    public static double4x4 Translate(double3 vector)
    Parameters
    Type Name Description
    double3 vector

    The translation vector.

    Returns
    Type Description
    double4x4

    The double4x4 translation matrix.

    TRS(double3, quaternion, float3)

    Returns a double4x4 matrix representing a combined scale-, rotation- and translation transform. Equivalent to mul(translationTransform, mul(rotationTransform, scaleTransform)).

    Declaration
    public static double4x4 TRS(double3 translation, quaternion rotation, float3 scale)
    Parameters
    Type Name Description
    double3 translation

    The translation vector.

    quaternion rotation

    The quaternion rotation.

    float3 scale

    The scaling factors of each axis.

    Returns
    Type Description
    double4x4

    The double4x4 matrix representing the translation, rotation, and scale by the inputs.

    Back to top Generated by DocFX