コード例 #1
0
        public override Vector2 <decimal> EquatorialCoordinates(DateTime date)
        {
            var pos = EclipticEarth3D(date);
            var X = pos.X; var Y = pos.Y; var Z = pos.Z;
            var R         = DecimalMath.Sqrt(X * X + Y * Y + Z * Z);
            var lambda    = DecimalMath.Atan2(Y, X);
            var sinLambda = DecimalMath.Sin(lambda);
            var cosLambda = DecimalMath.Cos(lambda);
            var beta      = DecimalMath.Asin(Z / R);
            var tanBeta   = DecimalMath.Tan(beta);
            var sinBeta   = DecimalMath.Sin(beta);
            var cosBeta   = DecimalMath.Cos(beta);

            var tilt    = CommonCalculations.GetAxialTilt(date) * DecimalMath.DegToRad;
            var cosTilt = DecimalMath.Cos(tilt);
            var sinTilt = DecimalMath.Sin(tilt);
            var RA      = DecimalMath.Atan2(sinLambda * cosTilt - tanBeta * sinTilt, cosLambda) * DecimalMath.RadToDeg;
            var Dec     = DecimalMath.Asin(sinBeta * cosTilt + cosBeta * sinTilt * sinLambda) * DecimalMath.RadToDeg;

            RA = CommonCalculations.From0To360(RA);
#if DEBUG
            Console.WriteLine($"R = {R} lambda = {lambda}, beta = {beta}, tilt = {tilt}, RA = {RA}, dec = {Dec}");
#endif

            return(new Vector2 <decimal>(RA, Dec));
        }
コード例 #2
0
        public Vector2 <decimal> EquatorialCoordinates(DateTime date)
        {
            var DegToRad = DecimalMath.DegToRad;

            var d = JulianDateCalculator.ToJulianDaysJ2000(date);
            var L = FL(d); var Lrad = L * DegToRad;
            var M = FMMoon(d); var Mrad = M * DegToRad;
            var F = FF(d); var Frad = F * DegToRad;

            var lambda = (L + 6.289M * DecimalMath.Sin(Mrad)) * DegToRad;
            var beta   = (5.128m * DecimalMath.Sin(Frad)) * DegToRad;
            var tilt   = CommonCalculations.GetAxialTilt(date) * DegToRad;

            var sinLambda = DecimalMath.Sin(lambda);
            var cosLambda = DecimalMath.Cos(lambda);

            var sinBeta = DecimalMath.Sin(beta);
            var cosBeta = DecimalMath.Cos(beta);
            var tanBeta = DecimalMath.Tan(beta);

            var sinTilt = DecimalMath.Sin(tilt);
            var cosTilt = DecimalMath.Cos(tilt);

            var RA  = DecimalMath.Atan2(sinLambda * cosTilt - tanBeta * sinTilt, cosLambda) * DecimalMath.RadToDeg;
            var Dec = DecimalMath.Asin(sinBeta * cosTilt + cosBeta * sinTilt * sinLambda) * DecimalMath.RadToDeg;

            return(new Vector2 <decimal>(CommonCalculations.From0To360(RA), Dec));
        }
コード例 #3
0
        public void TanSqrt3()
        {
            const decimal THREE    = 3.0M;
            decimal       expected = DecimalMath.Sqrt(THREE);
            decimal       actual   = DecimalMath.PI / THREE;

            actual = DecimalMath.Tan(actual);

            expected = Math.Round(expected, 22);    //1.7320508075688772935274463415
            actual   = Math.Round(actual, 22);      //1.7320508075688772935274463414

            Assert.AreEqual <decimal>(expected, actual);
        }
コード例 #4
0
        public static decimal GetAscendant(double longi, double lat, DateTime dateTime, bool isVedic = true)
        {
            var Pi          = DecimalMath.Pi;
            var DegToRad    = Pi / 180;
            var longitude   = Convert.ToDecimal(-longi); // East should be positive, West negative
            var latitudeRad = Convert.ToDecimal(lat) * DegToRad;
            var tilt        = CommonCalculations.GetAxialTilt(dateTime);
            var tiltRad     = tilt * DegToRad;

#if DEBUG
            Console.WriteLine($"tilt: {tilt}");
#endif
            var siderealTime    = SiderealTime.Calculate(longitude, dateTime);
            var siderealTimeRad = siderealTime * DegToRad;
#if DEBUG
            Console.WriteLine($"sidereal Time: {siderealTime}");
#endif
            var y = -DecimalMath.Cos(siderealTimeRad);
#if DEBUG
            Console.WriteLine($"y :{y}");
            Console.WriteLine(
                $"sin(RAMC) = {DecimalMath.Sin(siderealTimeRad)}" +
                $"\ncos(TILT) = {DecimalMath.Cos(tiltRad)}" +
                $"\ntan(LAT) = {DecimalMath.Tan(latitudeRad)}" +
                $"\nsin(TILT) = {DecimalMath.Sin(tiltRad)}");
#endif
            var x = DecimalMath.Sin(siderealTimeRad) * DecimalMath.Cos(tiltRad)
                    + DecimalMath.Tan(latitudeRad) * DecimalMath.Sin(tiltRad);
#if DEBUG
            Console.WriteLine($"x :{x}");
            Console.WriteLine($"Decimal y/x: {y / x}");
            Console.WriteLine($"Atan(y/x): {DecimalMath.ATan(y / x)}");
#endif
            var output = DecimalMath.ATan(y / x) * 180 / Pi;

            if (output < 0)
            {
                output += 180;
            }
            if (siderealTimeRad > Pi / 2 && siderealTimeRad < 3 * Pi / 2)
            {
                output += 180;
                output %= 360;
            }
#if DEBUG
            Console.WriteLine($"output before applying sidereal diff{output}");
#endif
            return(output);
        }
コード例 #5
0
        public decimal calculate(Queue <string> polska, decimal x)
        {
            decimal answer = 0;

            Stack <decimal> opers = new Stack <decimal>();

            foreach (string s in polska)
            {
                if (standartOperators.Contains(s))
                {
                    decimal a;
                    decimal b;

                    switch (s)
                    {
                    case "+":
                        opers.Push(opers.Pop() + opers.Pop());
                        break;

                    case "-":
                        b = opers.Pop();
                        a = opers.Pop();
                        opers.Push(a - b);
                        break;

                    case "*":
                        opers.Push(opers.Pop() * opers.Pop());
                        break;

                    case "/":
                        b = opers.Pop();
                        a = opers.Pop();
                        opers.Push(a / b);
                        break;

                    case "^":
                        b = opers.Pop();
                        a = opers.Pop();
                        opers.Push(DecimalMath.Pow(a, b));
                        break;

                    case "%":
                        b = opers.Pop();
                        a = opers.Pop();
                        opers.Push(a % b);
                        break;

                    case "sqrt":
                        opers.Push(DecimalMath.Sqrt(opers.Pop()));
                        break;

                    case "sin":
                        opers.Push(DecimalMath.Sin(opers.Pop()));
                        break;

                    case "cos":
                        opers.Push(DecimalMath.Cos(opers.Pop()));
                        break;

                    case "tan":
                        opers.Push(DecimalMath.Tan(opers.Pop()));
                        break;

                    case "atan":
                        opers.Push(DecimalMath.Atan(opers.Pop()));
                        break;

                    case "acos":
                        opers.Push(DecimalMath.Acos(opers.Pop()));
                        break;

                    case "asin":
                        opers.Push(DecimalMath.Asin(opers.Pop()));
                        break;

                    case "acotan":
                        opers.Push(DecimalMath.Atan(1 / opers.Pop()));
                        break;

                    case "exp":
                        opers.Push(DecimalMath.Exp(opers.Pop()));
                        break;

                    case "log":
                        opers.Push(DecimalMath.Log(opers.Pop()));
                        break;

                    case "ln":
                        opers.Push(DecimalMath.Log10(opers.Pop()));
                        break;

                    case "sinh":
                        opers.Push(DecimalMath.Sinh(opers.Pop()));
                        break;

                    case "cosh":
                        opers.Push(DecimalMath.Cosh(opers.Pop()));
                        break;

                    case "tanh":
                        opers.Push(DecimalMath.Tanh(opers.Pop()));
                        break;

                    case "abs":
                        opers.Push(DecimalMath.Abs(opers.Pop()));
                        break;

                    case "ceil":
                        opers.Push(DecimalMath.Ceiling(opers.Pop()));
                        break;

                    case "floor":
                        opers.Push(DecimalMath.Floor(opers.Pop()));
                        break;

                    case "fac":
                        opers.Push(factorial(opers.Pop()));
                        break;

                    case "sfac":
                        opers.Push(semifactorial(opers.Pop()));
                        break;

                    case "round":
                        opers.Push(DecimalMath.Round(opers.Pop()));
                        break;

                    case "fpart":
                        a = opers.Pop();
                        opers.Push(a - DecimalMath.Truncate(a));
                        break;
                    }
                }
                else if (s == "x")
                {
                    opers.Push(x);
                }
                else
                {
                    opers.Push(decimal.Parse(s));
                }
            }

            answer = opers.Pop();
            return(answer);
        }
コード例 #6
0
 public void TanException()
 {
     Assert.ThrowsException <ArgumentOutOfRangeException>(() => DecimalMath.Tan(DecimalMath.PI / 2));
 }