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

    • High Precision Framework
      • Installation
      • Getting Started
      • Overview
      • Try It With Our Sample Scene
      • Known Limitations
      • Using Unity Mathematics

    Transition from Unity Engine to Unity Mathematics

    Multiplication

    Instead of using the * operator when multiplying vectors and matrices, use the math.mul method.

    # Engine
    Vector3 x = new Vector3(1, 2, 3);
    Vector3 y = new Vector3(4, 5, 6);
    Vector3 z = x * y;
    
    # Mathematics
    float3 x = new float3(1, 2, 3);
    float3 y = new float3(4, 5, 6);
    float3 z = math.mul(x, y);
    

    Quaternion

    Mathematics quaternion are stored in radian values.

    Methods Ownership

    Many class / struct methods, has inverting matrices, are now static methods part of the math library. We also added a few in HPMath.

    # Engine
    Quaternion rot = Quaternion.Euler(30, 0, 0);
    Matrix4x4 m = Matrix4x4.TRS(Vector3.zero, rot, Vector3.one);
    Matrix4x4 inv = m.inverse;
    
    # Mathematics
    quaternion rot = HPMath.EulerZXYDegrees(30, 0, 0);
    double4x4 m = HPMath.TRS(double3.zero, rot, new float3(1f);
    Matrix4x4 inv = math.inverse(m);
    

    Normalization

    You can normalize a double3 with math.normalize method, but if you want the same behaviour you had with Unity Engine, you must use math.normalizesafe.

    Changes from v0.3.3

    • DBounds have been renamed to DoubleBounds
    • DPlane have been renamed to DoublePlane
    • DMatrix4x4 have been replaced with double4x4
    • DVector2 have been replaced with double2
    • DVector3 have been replaced with double3
    • DVector4 have been replaced with double4
    Back to top Generated by DocFX