Example #1
0
        public static void sincos(out FixFactor s, out FixFactor c, long nom, long den)
        {
            int index = SinCosLut.getIndex(nom, den);

            s = new FixFactor((long)SinCosLut.sin_table[index], (long)SinCosLut.FACTOR);
            c = new FixFactor((long)SinCosLut.cos_table[index], (long)SinCosLut.FACTOR);
        }
Example #2
0
        public static void sincos(out FixFactor s, out FixFactor c, FixFactor angle)
        {
            int index = SinCosLut.getIndex(angle.nom, angle.den);

            s = new FixFactor((long)SinCosLut.sin_table[index], (long)SinCosLut.FACTOR);
            c = new FixFactor((long)SinCosLut.cos_table[index], (long)SinCosLut.FACTOR);
        }
Example #3
0
        public static FixFactor operator -(FixFactor a, FixFactor b)
        {
            FixFactor factor = new FixFactor();

            factor.nom = (a.nom * b.den) - (b.nom * a.den);
            factor.den = a.den * b.den;
            return(factor);
        }
Example #4
0
 static FixFactor()
 {
     zero   = new FixFactor(0L, 1L);
     one    = new FixFactor(1L, 1L);
     pi     = new FixFactor(0x7ab8L, 0x2710L);
     twoPi  = new FixFactor(0xf570L, 0x2710L);
     mask_  = 0x7fffffffffffffffL;
     upper_ = 0xffffffL;
 }
Example #5
0
        public static FixFactor acos(long nom, long den)
        {
            int index = ((int)Divide((long)(nom * AcosLut.HALF_COUNT), den)) + AcosLut.HALF_COUNT;

            index = Mathf.Clamp(index, 0, AcosLut.COUNT);
            FixFactor factor = new FixFactor();

            factor.nom = AcosLut.table[index];
            factor.den = 0x2710L;
            return(factor);
        }
Example #6
0
        public FixVector3 RotateY(ref FixFactor radians)
        {
            FixVector3 num;
            FixFactor  factor;
            FixFactor  factor2;

            Fix32Math.sincos(out factor, out factor2, radians.nom, radians.den);
            long num2 = factor2.nom * factor.den;
            long num3 = factor2.den * factor.nom;
            long b    = factor2.den * factor.den;

            num.x = (int)Fix32Math.Divide((long)((this.x * num2) + (this.z * num3)), b);
            num.z = (int)Fix32Math.Divide((long)((-this.x * num3) + (this.z * num2)), b);
            num.y = 0;
            return(num.NormalizeTo(0x3e8));
        }
Example #7
0
        public static FixFactor atan2(int y, int x)
        {
            int num;
            int num2;

            if (x < 0)
            {
                if (y < 0)
                {
                    x    = -x;
                    y    = -y;
                    num2 = 1;
                }
                else
                {
                    x    = -x;
                    num2 = -1;
                }
                num = -31416;
            }
            else
            {
                if (y < 0)
                {
                    y    = -y;
                    num2 = -1;
                }
                else
                {
                    num2 = 1;
                }
                num = 0;
            }
            int       dIM    = Atan2Lut.DIM;
            long      num4   = dIM - 1;
            long      b      = (x >= y) ? ((long)x) : ((long)y);
            int       num6   = (int)Divide((long)(x * num4), b);
            int       num7   = (int)Divide((long)(y * num4), b);
            int       num8   = Atan2Lut.table[(num7 * dIM) + num6];
            FixFactor factor = new FixFactor();

            factor.nom = (num8 + num) * num2;
            factor.den = 0x2710L;
            return(factor);
        }
Example #8
0
 public static FixVector3 Lerp(FixVector3 a, FixVector3 b, FixFactor f)
 {
     return(new FixVector3(((int)Fix32Math.Divide((long)((b.x - a.x) * f.nom), f.den)) + a.x, ((int)Fix32Math.Divide((long)((b.y - a.y) * f.nom), f.den)) + a.y, ((int)Fix32Math.Divide((long)((b.z - a.z) * f.nom), f.den)) + a.z));
 }