Пример #1
0
        public static FInt Sqrt(FInt f)
        {
            byte numberOfIterations = 8;

            if (f.RawValue > 0x64000)
            {
                numberOfIterations = 12;
            }
            if (f.RawValue > 0x3e8000)
            {
                numberOfIterations = 16;
            }
            return(Sqrt(f, numberOfIterations));
        }
Пример #2
0
        public static FInt Asin(FInt F)
        {
            bool isNegative = F < 0;

            F = Abs(F);

            if (F > FInt.OneF)
            {
                throw new ArithmeticException("Bad Asin Input:" + F.ToDouble());
            }

            FInt f1 = mul(mul(mul(mul(FInt.Create(145103 >> FInt.SHIFT_AMOUNT, false), F) -
                                  FInt.Create(599880 >> FInt.SHIFT_AMOUNT, false), F) +
                              FInt.Create(1420468 >> FInt.SHIFT_AMOUNT, false), F) -
                          FInt.Create(3592413 >> FInt.SHIFT_AMOUNT, false), F) +
                      FInt.Create(26353447 >> FInt.SHIFT_AMOUNT, false);
            FInt f2 = PI / FInt.Create(2, true) - (Sqrt(FInt.OneF - F) * f1);

            return(isNegative ? f2.Inverse : f2);
        }
Пример #3
0
        public static FInt Sin(FInt i)
        {
            FInt j = (FInt)0;

            for (; i < 0; i += FInt.Create(25736, false))
            {
                ;
            }
            if (i > FInt.Create(25736, false))
            {
                i %= FInt.Create(25736, false);
            }
            FInt k = (i * FInt.Create(10, false)) / FInt.Create(714, false);

            if (i != 0 && i != FInt.Create(6434, false) && i != FInt.Create(12868, false) &&
                i != FInt.Create(19302, false) && i != FInt.Create(25736, false))
            {
                j = (i * FInt.Create(100, false)) / FInt.Create(714, false) - k * FInt.Create(10, false);
            }
            if (k <= FInt.Create(90, false))
            {
                return(sin_lookup(k, j));
            }
            if (k <= FInt.Create(180, false))
            {
                return(sin_lookup(FInt.Create(180, false) - k, j));
            }
            if (k <= FInt.Create(270, false))
            {
                return(sin_lookup(k - FInt.Create(180, false), j).Inverse);
            }
            else
            {
                return(sin_lookup(FInt.Create(360, false) - k, j).Inverse);
            }
        }
Пример #4
0
 public static FInt Atan(FInt F)
 {
     return(Asin(F / Sqrt(FInt.OneF + (F * F))));
 }
Пример #5
0
 public static FInt Tan(FInt i)
 {
     return(Sin(i) / Cos(i));
 }
Пример #6
0
 public static FInt Cos(FInt i)
 {
     return(Sin(i + FInt.Create(6435, false)));
 }
Пример #7
0
 private static FInt mul(FInt F1, FInt F2)
 {
     return(F1 * F2);
 }
Пример #8
0
 public static FInt operator >>(FInt one, int amount)
 {
     return(FInt.Create(one.RawValue >> amount, false));
 }