예제 #1
0
    void FixPointCSTest()
    {
        FixMath.F64 angle  = new FixMath.F64(30);
        FixMath.F64 angle2 = new FixMath.F64(180);

        FixMath.F64 angle3 = angle * FixMath.F64.Pi / angle2;

        //public static F64 DegToRad(F64 a) { return FromRaw(Fixed64.Mul(a.Raw, 74961320)); }     // F64.Pi / 180
        FixMath.F64 angle4 = FixMath.F64.DegToRad(angle);
        FixMath.F64 angle5 = FixMath.F64.DegToRad2(angle);
        Debug.LogError(FixMath.F64.Sin(angle3));
        Debug.LogError(FixMath.F64.Sin(angle4));
        Debug.LogError(FixMath.F64.Sin(angle5));


        //
        F64Vec3 FA     = new F64Vec3(0f, 0f, 1f);
        F64Vec3 FB     = new F64Vec3(1f, 0f, 0f);
        F64     Fangle = F64Vec3.Angle(FA, FB);

        Debug.LogError(Fangle.Float);
        F64Vec3 cross = F64Vec3.Cross(FA, FB);

        Debug.LogError(cross.ToUnityVector3());


        Vector3 A      = new Vector3(0f, 0f, 1f);
        Vector3 B      = new Vector3(1f, 0f, 0f);
        float   angle6 = Vector3.Angle(A, B);

        Debug.LogError(angle6);
    }
예제 #2
0
 [MethodImpl(FixedUtil.AggressiveInlining)] public static F32 FromF64(F64 v)
 {
     return(FromRaw((int)(v.Raw >> 16)));
 }
예제 #3
0
 public static F64 LengthSqr(F32Vec3 a)
 {
     return(F64.FromRaw((long)a.RawX * (long)a.RawX + (long)a.RawY * (long)a.RawY + (long)a.RawZ * (long)a.RawZ));
 }
예제 #4
0
 public F64Vec3(F64 x, F64 y, F64 z)
 {
     RawX = x.Raw;
     RawY = y.Raw;
     RawZ = z.Raw;
 }
예제 #5
0
 public static F64 Dot(F64Vec3 a, F64Vec3 b)
 {
     return(F64.FromRaw(Fixed64.Mul(a.RawX, b.RawX) + Fixed64.Mul(a.RawY, b.RawY) + Fixed64.Mul(a.RawZ, b.RawZ)));
 }
예제 #6
0
 public static F64Vec3 NormalizeFastest(F64Vec3 a)
 {
     F64 ooLen = F64.FromRaw(Fixed64.RSqrtFastest(Fixed64.Mul(a.RawX, a.RawX) + Fixed64.Mul(a.RawY, a.RawY) + Fixed64.Mul(a.RawZ, a.RawZ))); return(ooLen * a);
 }
예제 #7
0
 public static F64 LengthFastest(F64Quat a)
 {
     return(F64.SqrtFastest(LengthSqr(a)));
 }
예제 #8
0
 public static F64Vec2 PowFastest(F64Vec2 a, F64 b)
 {
     return(new F64Vec2(Fixed64.PowFastest(a.RawX, b.Raw), Fixed64.PowFastest(a.RawY, b.Raw)));
 }
예제 #9
0
 public static F64Vec3 PowFast(F64Vec3 a, F64 b)
 {
     return(new F64Vec3(Fixed64.PowFast(a.RawX, b.Raw), Fixed64.PowFast(a.RawY, b.Raw), Fixed64.PowFast(a.RawZ, b.Raw)));
 }
예제 #10
0
 public static F64Vec3 Div(F64Vec3 a, F64 b)
 {
     long oob = Fixed64.Rcp(b.Raw); return(new F64Vec3(Fixed64.Mul(a.RawX, oob), Fixed64.Mul(a.RawY, oob), Fixed64.Mul(a.RawZ, oob)));
 }
예제 #11
0
 public F32(F64 v)
 {
     Raw = (int)(v.Raw >> 16);
 }
예제 #12
0
 public static F32 FromF64(F64 v)
 {
     return(new F32(v));
 }
예제 #13
0
        public static F64Quat FromAxisAngle(F64Vec3 axis, F64 angle)
        {
            F64 half_angle = F64.Div2(angle);

            return(new F64Quat(axis * F64.SinFastest(half_angle), F64.CosFastest(half_angle)));
        }
예제 #14
0
 public F64Vec3(float x, float y, float z)
 {
     this.RawX = F64.FromFloat(x).Raw;
     this.RawY = F64.FromFloat(y).Raw;
     this.RawZ = F64.FromFloat(z).Raw;
 }
예제 #15
0
 public static F64Vec3 PowFastest(F64 a, F64Vec3 b)
 {
     return(new F64Vec3(Fixed64.PowFastest(a.Raw, b.RawX), Fixed64.PowFastest(a.Raw, b.RawY), Fixed64.PowFastest(a.Raw, b.RawZ)));
 }
예제 #16
0
 public static F64Vec2 DivFastest(F64Vec2 a, F64 b)
 {
     long oob = Fixed64.RcpFastest(b.Raw); return(new F64Vec2(Fixed64.Mul(a.RawX, oob), Fixed64.Mul(a.RawY, oob)));
 }
예제 #17
0
 public static F64 LengthSqr(F64Vec3 a)
 {
     return(F64.FromRaw(Fixed64.Mul(a.RawX, a.RawX) + Fixed64.Mul(a.RawY, a.RawY) + Fixed64.Mul(a.RawZ, a.RawZ)));
 }
예제 #18
0
 public static F64Vec2 PowFastest(F64 a, F64Vec2 b)
 {
     return(new F64Vec2(Fixed64.PowFastest(a.Raw, b.RawX), Fixed64.PowFastest(a.Raw, b.RawY)));
 }
예제 #19
0
 public static F64 Length(F64Quat a)
 {
     return(F64.Sqrt(LengthSqr(a)));
 }