Example #1
0
 /// <summary>
 /// Returns a hash code for this <see cref="Rotation" />.
 /// </summary>
 /// <returns>An integer value that specifies the hash code for this <see cref="Rotation" />.</returns>
 public override int GetHashCode() => Degrees.GetHashCode();
Example #2
0
 /// <summary>
 ///     Compare this Angle to another Angle for equality.  Angle comparisons
 ///     are performed in absolute terms - no "wrapping" occurs.  In other
 ///     words, 360 degress != 0 degrees.
 /// </summary>
 /// <param name="other">other Angle to compare to</param>
 /// <returns>'true' if angles are equal</returns>
 public bool Equals(Angle other)
 {
     return(Degrees.IsApproximatelyEqual(other.Degrees, Precision));
 }
Example #3
0
 /// <summary>
 /// Get coordinates as a string.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     //return ToString("D6", System.Globalization.CultureInfo.InvariantCulture);
     return(Degrees.ToString(System.Globalization.CultureInfo.InvariantCulture));
 }
Example #4
0
        public override string ToString()
        {
            string s = "R: " + R.ToString("F3") + ", Theta: " + Degrees.ToString("F3") + "° (" + X.ToString("F2") + "," + Y.ToString("F2") + ") Rot:" + rotation;

            return(s);
        }
Example #5
0
 public AngleChangedEventArgs(double rad)
 {
     Radians = rad;
     Degrees = (int)(rad * 180 / Math.PI);
     Text    = Degrees.ToString();
 }
Example #6
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]         = new Abs();
     Functions["asin"]        = new Asin();
     Functions["asinh"]       = new Asinh();
     Functions["cos"]         = new Cos();
     Functions["cosh"]        = new Cosh();
     Functions["power"]       = new Power();
     Functions["sign"]        = new Sign();
     Functions["sqrt"]        = new Sqrt();
     Functions["sqrtpi"]      = new SqrtPi();
     Functions["pi"]          = new Pi();
     Functions["product"]     = new Product();
     Functions["ceiling"]     = new Ceiling();
     Functions["count"]       = new Count();
     Functions["counta"]      = new CountA();
     Functions["countblank"]  = new CountBlank();
     Functions["countif"]     = new CountIf();
     Functions["countifs"]    = new CountIfs();
     Functions["fact"]        = new Fact();
     Functions["floor"]       = new Floor();
     Functions["sin"]         = new Sin();
     Functions["sinh"]        = new Sinh();
     Functions["sum"]         = new Sum();
     Functions["sumif"]       = new SumIf();
     Functions["sumifs"]      = new SumIfs();
     Functions["sumproduct"]  = new SumProduct();
     Functions["sumsq"]       = new Sumsq();
     Functions["stdev"]       = new Stdev();
     Functions["stdevp"]      = new StdevP();
     Functions["stdev.s"]     = new Stdev();
     Functions["stdev.p"]     = new StdevP();
     Functions["subtotal"]    = new Subtotal();
     Functions["exp"]         = new Exp();
     Functions["log"]         = new Log();
     Functions["log10"]       = new Log10();
     Functions["ln"]          = new Ln();
     Functions["max"]         = new Max();
     Functions["maxa"]        = new Maxa();
     Functions["median"]      = new Median();
     Functions["min"]         = new Min();
     Functions["mina"]        = new Mina();
     Functions["mod"]         = new Mod();
     Functions["average"]     = new Average();
     Functions["averagea"]    = new AverageA();
     Functions["averageif"]   = new AverageIf();
     Functions["averageifs"]  = new AverageIfs();
     Functions["round"]       = new Round();
     Functions["rounddown"]   = new Rounddown();
     Functions["roundup"]     = new Roundup();
     Functions["rand"]        = new Rand();
     Functions["randbetween"] = new RandBetween();
     Functions["quotient"]    = new Quotient();
     Functions["trunc"]       = new Trunc();
     Functions["tan"]         = new Tan();
     Functions["tanh"]        = new Tanh();
     Functions["atan"]        = new Atan();
     Functions["atan2"]       = new Atan2();
     Functions["atanh"]       = new Atanh();
     Functions["acos"]        = new Acos();
     Functions["acosh"]       = new Acosh();
     Functions["var"]         = new Var();
     Functions["varp"]        = new VarP();
     Functions["large"]       = new Large();
     Functions["small"]       = new Small();
     Functions["degrees"]     = new Degrees();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     // Logical
     Functions["if"]      = new If();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     // Reference and lookup
     Functions["address"] = new Address();
     Functions["hlookup"] = new HLookup();
     Functions["vlookup"] = new VLookup();
     Functions["lookup"]  = new Lookup();
     Functions["match"]   = new Match();
     Functions["row"]     = new Row()
     {
         SkipArgumentEvaluation = true
     };
     Functions["rows"] = new Rows()
     {
         SkipArgumentEvaluation = true
     };
     Functions["column"] = new Column()
     {
         SkipArgumentEvaluation = true
     };
     Functions["columns"] = new Columns()
     {
         SkipArgumentEvaluation = true
     };
     Functions["choose"]   = new Choose();
     Functions["index"]    = new Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset()
     {
         SkipArgumentEvaluation = true
     };
     // Date
     Functions["date"]       = new Date();
     Functions["today"]      = new Today();
     Functions["now"]        = new Now();
     Functions["day"]        = new Day();
     Functions["month"]      = new Month();
     Functions["year"]       = new Year();
     Functions["time"]       = new Time();
     Functions["hour"]       = new Hour();
     Functions["minute"]     = new Minute();
     Functions["second"]     = new Second();
     Functions["weeknum"]    = new Weeknum();
     Functions["weekday"]    = new Weekday();
     Functions["days360"]    = new Days360();
     Functions["yearfrac"]   = new Yearfrac();
     Functions["edate"]      = new Edate();
     Functions["eomonth"]    = new Eomonth();
     Functions["isoweeknum"] = new IsoWeekNum();
     Functions["workday"]    = new Workday();
 }
Example #7
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <returns>
 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 /// <param name="other">An object to compare with this object.</param>
 public virtual bool Equals(int other)
 => Degrees.Equals(other);
Example #8
0
 /// <summary>
 /// Turns the object based on the sign of the rate parameter.
 /// </summary>
 /// <param name="rate">The degrees per second rate of turn. If negative, the object will turn left, else it will turn right.</param>
 protected void turn(float rate)
 {
     curDir += (float)(rate * Common.intervalMS / 1000);
     curDir  = Degrees.getDegreeValue(curDir);
     Interlocked.Exchange(ref m_direction, (int)Math.Floor(curDir));
 }
Example #9
0
 /// <summary>
 /// Compares the current object with another object of the same type.
 /// </summary>
 /// <returns>
 /// A value that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the <paramref name="other"/> parameter.Zero This object is equal to <paramref name="other"/>. Greater than zero This object is greater than <paramref name="other"/>.
 /// </returns>
 /// <param name="other">An object to compare with this object.</param>
 public int CompareTo(int other)
 {
     return(Degrees.CompareTo(other));
 }
Example #10
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <returns>
 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 /// <param name="other">An object to compare with this object.</param>
 public virtual bool Equals(double other)
 => Degrees.Equals(other);
Example #11
0
 public override void use()
 {
     playSound(launch, true, false);
     z         = origTarget.z;
     direction = Degrees.GetDegreesBetween(x, y, origTarget.x, origTarget.y);
 }
Example #12
0
 public void Degrees_2_hours()
 {
     FloatCompare(24, Degrees.Hours(360), 3);
 }
Example #13
0
 public void Degrees_2_radians()
 {
     FloatCompare(TAU, Degrees.Radians(360));
 }
Example #14
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["concat"]      = new Concat();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value();
     Functions["trim"]        = new Trim();
     Functions["clean"]       = new Clean();
     Functions["unicode"]     = new Unicode();
     Functions["unichar"]     = new Unichar();
     Functions["numbervalue"] = new NumberValue();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]             = new Abs();
     Functions["asin"]            = new Asin();
     Functions["asinh"]           = new Asinh();
     Functions["acot"]            = new Acot();
     Functions["acoth"]           = new Acoth();
     Functions["cos"]             = new Cos();
     Functions["cot"]             = new Cot();
     Functions["coth"]            = new Coth();
     Functions["cosh"]            = new Cosh();
     Functions["csc"]             = new Csc();
     Functions["csch"]            = new Csch();
     Functions["power"]           = new Power();
     Functions["gcd"]             = new Gcd();
     Functions["lcm"]             = new Lcm();
     Functions["sec"]             = new Sec();
     Functions["sech"]            = new SecH();
     Functions["sign"]            = new Sign();
     Functions["sqrt"]            = new Sqrt();
     Functions["sqrtpi"]          = new SqrtPi();
     Functions["pi"]              = new Pi();
     Functions["product"]         = new Product();
     Functions["ceiling"]         = new Ceiling();
     Functions["ceiling.precise"] = new CeilingPrecise();
     Functions["ceiling.math"]    = new CeilingMath();
     Functions["iso.ceiling"]     = new IsoCeiling();
     Functions["combin"]          = new Combin();
     Functions["combina"]         = new Combina();
     Functions["count"]           = new Count();
     Functions["counta"]          = new CountA();
     Functions["countblank"]      = new CountBlank();
     Functions["countif"]         = new CountIf();
     Functions["countifs"]        = new CountIfs();
     Functions["fact"]            = new Fact();
     Functions["factdouble"]      = new FactDouble();
     Functions["floor"]           = new Floor();
     Functions["floor.precise"]   = new FloorPrecise();
     Functions["floor.math"]      = new FloorMath();
     Functions["radians"]         = new Radians();
     Functions["roman"]           = new Roman();
     Functions["sin"]             = new Sin();
     Functions["sinh"]            = new Sinh();
     Functions["sum"]             = new Sum();
     Functions["sumif"]           = new SumIf();
     Functions["sumifs"]          = new SumIfs();
     Functions["sumproduct"]      = new SumProduct();
     Functions["sumsq"]           = new Sumsq();
     Functions["sumxmy2"]         = new Sumxmy2();
     Functions["sumx2my2"]        = new SumX2mY2();
     Functions["sumx2py2"]        = new SumX2pY2();
     Functions["seriessum"]       = new Seriessum();
     Functions["stdev"]           = new Stdev();
     Functions["stdevp"]          = new StdevP();
     Functions["stdev.s"]         = new Stdev();
     Functions["stdev.p"]         = new StdevP();
     Functions["subtotal"]        = new Subtotal();
     Functions["exp"]             = new Exp();
     Functions["log"]             = new Log();
     Functions["log10"]           = new Log10();
     Functions["ln"]              = new Ln();
     Functions["max"]             = new Max();
     Functions["maxa"]            = new Maxa();
     Functions["median"]          = new Median();
     Functions["min"]             = new Min();
     Functions["mina"]            = new Mina();
     Functions["mod"]             = new Mod();
     Functions["mround"]          = new Mround();
     Functions["average"]         = new Average();
     Functions["averagea"]        = new AverageA();
     Functions["averageif"]       = new AverageIf();
     Functions["averageifs"]      = new AverageIfs();
     Functions["round"]           = new Round();
     Functions["rounddown"]       = new Rounddown();
     Functions["roundup"]         = new Roundup();
     Functions["rand"]            = new Rand();
     Functions["randbetween"]     = new RandBetween();
     Functions["rank"]            = new Rank();
     Functions["rank.eq"]         = new Rank();
     Functions["rank.avg"]        = new Rank(true);
     Functions["quotient"]        = new Quotient();
     Functions["trunc"]           = new Trunc();
     Functions["tan"]             = new Tan();
     Functions["tanh"]            = new Tanh();
     Functions["atan"]            = new Atan();
     Functions["atan2"]           = new Atan2();
     Functions["atanh"]           = new Atanh();
     Functions["acos"]            = new Acos();
     Functions["acosh"]           = new Acosh();
     Functions["var"]             = new Var();
     Functions["varp"]            = new VarP();
     Functions["large"]           = new Large();
     Functions["small"]           = new Small();
     Functions["degrees"]         = new Degrees();
     Functions["odd"]             = new Odd();
     Functions["even"]            = new Even();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     Functions["type"]       = new TypeFunction();
     // Logical
     Functions["if"]      = new If();
     Functions["ifs"]     = new Ifs();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     Functions["switch"]  = new Switch();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days"]             = new Days();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["workday.intl"]     = new WorkdayIntl();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["pmt"] = new Pmt();
 }
Example #15
0
 public static bool inRange(Projector weapon, Projector target, Range r)
 {
     return((Degrees.getDistanceBetween(weapon.x, weapon.y,
                                        target.x, target.y) <= r.horizontalDistance) &&
            (Math.Abs(weapon.z - target.z) <= r.verticalDistance));
 }
Example #16
0
 /// <summary>
 /// Gets the radius of a turn.
 /// </summary>
 /// <returns>The radius in feet.</returns>
 protected float getTurnRadius()
 {
     return((float)(Math.Pow(Common.convertToKNOTS(getHorizontalSpeed()), 2) / (11.26 * Math.Tan(Degrees.toRadians(bankAngle)))));
 }
Example #17
0
        private static void ProcessFiles(string inputPath, string outputPath)
        {
            var sw      = Stopwatch.StartNew();
            var results = File.ReadAllLines(inputPath)
                          .Select(ParseLine)
                          .Select(GetFullerPoint)
                          .Select(r => $"{r.X}, {r.Y}")
                          .ToList();

            Console.WriteLine($"Read {results.Count} lines from '{inputPath} in {sw.Elapsed.TotalSeconds:N2} seconds'");

            File.WriteAllLines(outputPath, results);

            Console.WriteLine($"Successfully wrote to '{outputPath}'");

            Geodesic ParseLine(string line)
            {
                var elements = line.Split(',');

                return(new Geodesic(Angle.From(Degrees.FromRaw(double.Parse(elements[1]))), Angle.From(Degrees.FromRaw(double.Parse(elements[0])))));
            }
        }
Example #18
0
 /// <summary>
 /// Gets the relative position for a target.
 /// </summary>
 /// <param name="target">The object whose position needs to be obtained</param>
 /// <returns>A RelativePosition structure</returns>
 protected RelativePosition getPosition(Projector target)
 {
     return(Degrees.getPosition(x, y, z, direction,
                                target.x, target.y, target.z, target.direction,
                                target.isObject));
 }
        public static Quaternion GetSunPosition(double jday, double longitude, double latitude)
        {
            double d = jday - 2451543.5;

            double w = 282.9404 + 4.70935E-5 * d;
            double e = 0.016709 - 1.151E-9 * d;
            double M = Degrees.Normalize(356.0470 + 0.9856002585 * d);
            double E = Degrees.Normalize(M + Radians.ToDegrees(e) * Degrees.Sin(M) * (1 + e * Degrees.Cos(M)));

            double xv = Degrees.Cos(E) - e;
            double yv = Degrees.Sin(E) * Math.Sqrt(1 - e * e);

            double r   = Math.Sqrt(xv * xv + yv * yv);
            double lon = Degrees.Atan2(yv, xv) + w;
            double lat = 0;

            double rasc, decl;

            ConvertEclipticToEquatorial(jday, lon, lat, out rasc, out decl);
            ConvertEquatorialToHorizontal(jday, longitude, latitude, rasc, decl, out double azimuth, out double altitude);

            // convert to unity rotation azim, altitude y then x
            return(Quaternion.Euler(0f, (float)azimuth + 180.0f, 0f) * Quaternion.Euler((float)altitude, 0f, 0f));
        }
Example #20
0
 public Direction2D(Degrees angle)
     : this(angle.AsRadians())
 {
 }
        public static void GetSunRiseSet(TimeZoneInfo tz, DateTime dt, double longitude, double latitude, out float sunRiseStart, out float sunRiseEnd, out float sunSetStart, out float sunSetEnd)
        {
            // get julian day at noon
            var    utcNoon  = TimeZoneInfo.ConvertTimeToUtc(new DateTime(dt.Year, dt.Month, dt.Day, 12, 0, 0, DateTimeKind.Unspecified), tz);
            double jdayNoon = GetJulianDayFromGregorianDateTime(utcNoon);

            float sunUpperLimb = -0.833f;
            float sunLowerLimb = 3f; // more than lower limb at horizon to look better

            // magic
            double d = jdayNoon - 2451543.5;
            double w = 282.9404 + 4.70935E-5 * d;
            double e = 0.016709 - 1.151E-9 * d;
            double M = Degrees.Normalize(356.0470 + 0.9856002585 * d);
            double E = Degrees.Normalize(M + Radians.ToDegrees(e) * Degrees.Sin(M) * (1 + e * Degrees.Cos(M)));

            double xv  = Degrees.Cos(E) - e;
            double yv  = Degrees.Sin(E) * Math.Sqrt(1 - e * e);
            double lon = Degrees.Atan2(yv, xv) + w;
            double lat = 0;

            double rasc, decl;

            ConvertEclipticToEquatorial(jdayNoon, lon, lat, out rasc, out decl);

            double Ls           = Degrees.Normalize(w + M);
            double GMST         = Degrees.Normalize(Ls + 180);
            double UTSunInSouth = Degrees.Normalize(rasc - GMST - longitude) / 15.0f;

            var noonUtc = new DateTime(dt.Year, dt.Month, dt.Day, 12, 0, 0, DateTimeKind.Utc);
            var offset  = tz.GetUtcOffset(noonUtc);

            double cosLHA = (Degrees.Sin(sunUpperLimb) - Degrees.Sin(latitude) * Degrees.Sin(decl)) / (Degrees.Cos(latitude) * Degrees.Cos(decl));

            if (cosLHA < -1)
            {
                // never set
                sunRiseStart = 0;
                sunSetEnd    = 24;
            }
            else if (cosLHA > 1)
            {
                // never rise
                sunRiseStart = 24;
                sunSetEnd    = 0;
            }
            else
            {
                double LHA     = Degrees.Acos(cosLHA);
                double convert = LHA / 15f;

                sunRiseStart = (float)(UTSunInSouth - convert + offset.TotalHours);
                sunSetEnd    = (float)(UTSunInSouth + convert + offset.TotalHours);
            }

            cosLHA = (Degrees.Sin(sunLowerLimb) - Degrees.Sin(latitude) * Degrees.Sin(decl)) / (Degrees.Cos(latitude) * Degrees.Cos(decl));
            if (cosLHA < -1)
            {
                // never set
                sunRiseEnd  = 0;
                sunSetStart = 24;
            }
            else if (cosLHA > 1)
            {
                // never rise
                sunRiseEnd  = 24;
                sunSetStart = 0;
            }
            else
            {
                double LHA     = Degrees.Acos(cosLHA);
                double convert = LHA / 15f;

                sunRiseEnd  = (float)(UTSunInSouth - convert + offset.TotalHours);
                sunSetStart = (float)(UTSunInSouth + convert + offset.TotalHours);
            }
        }
        public void Calculates_dymaxion_points_from_geodesic_correctly(double longitude, double latitude, double expectedX, double expectedY)
        {
            var point = new Geodesic(Angle.From(Degrees.FromRaw(latitude)), Angle.From(Degrees.FromRaw(longitude)));

            var result = GetFullerPoint(point);

            Assert.Equal(new Cartesian2D(expectedX, expectedY), result);
        }
        static void GetEclipticMoonPosition(double jday, out double lon, out double lat, out double dist)
        {
            double d = jday - 2451543.5;

            double N  = 125.1228 - 0.0529538083 * d;  // long asc node
            double i  = 5.1454;                       // inclination
            double wm = 318.0634 + 0.1643573223 * d;  // arg of perigee
            double a  = 60.2666;                      // mean distance
            double e  = 0.054900;                     // eccentricity

            double ws = 282.9404 + 4.70935E-5 * d;

            double Ms = Degrees.Normalize(356.0470 + 0.9856002585 * d);  // Sun's mean anomaly
            double Mm = Degrees.Normalize(115.3654 + 13.0649929505 * d); // Moon's mean anomaly
            double Ls = Degrees.Normalize(ws + Ms);                      // Sun's mean longitude
            double Lm = Degrees.Normalize(N + wm + Mm);                  // Moon's mean longitude
            double D  = Degrees.Normalize(Lm - Ls);                      // Moon's mean elongation
            double F  = Degrees.Normalize(Lm - N);                       // Moon's argument of latitude

            double E0   = Mm + e * Degrees.Sin(Mm) * (1.0 + e * Degrees.Cos(Mm));
            double diff = 1.0;

            while (diff > 0.005)
            {
                double E1 = E0 - (E0 - e * Degrees.Sin(E0) - Mm) / (1.0 + e * Degrees.Cos(E0));
                diff = Math.Abs(E0 - E1);
                E0   = E1;
            }

            // rectangular coordinates in the plane of lunar orbit
            double x = a * (Degrees.Cos(E0) - e);
            double y = a * Math.Sqrt(1.0 - e * e) * Degrees.Sin(E0);

            // distance and true anomaly
            double r = Math.Sqrt(x * x + y * y);
            double v = Degrees.Atan2(y, x);

            // position in ecliptic coordinates
            double xe = Degrees.Cos(N) * Degrees.Cos(v + wm) - Degrees.Sin(N) * Degrees.Sin(v + wm) * Degrees.Cos(i);
            double ye = Degrees.Sin(N) * Degrees.Cos(v + wm) + Degrees.Cos(N) * Degrees.Sin(v + wm) * Degrees.Cos(i);
            double ze = Degrees.Sin(v + wm) * Degrees.Sin(i);

            double longitude = Degrees.Atan2(ye, xe);
            double latitude  = Degrees.Atan2(ze, Math.Sqrt(xe * xe + ye * ye));

            lon = longitude
                  - 1.274 * Degrees.Sin(Mm - 2 * D)    // Evection
                  + 0.658 * Degrees.Sin(2 * D)         // Variation
                  - 0.186 * Degrees.Sin(Ms)            // Yearly equation
                  - 0.059 * Degrees.Sin(2 * Mm - 2 * D)
                  - 0.057 * Degrees.Sin(Mm - 2 * D + Ms)
                  + 0.053 * Degrees.Sin(Mm + 2 * D)
                  + 0.046 * Degrees.Sin(2 * D - Ms)
                  + 0.041 * Degrees.Sin(Mm - Ms)
                  - 0.035 * Degrees.Sin(D)             // Parallactic equation
                  - 0.031 * Degrees.Sin(Mm + Ms)
                  - 0.015 * Degrees.Sin(2 * F - 2 * D)
                  + 0.011 * Degrees.Sin(Mm - 4 * D);

            lat = latitude
                  - 0.173 * Degrees.Sin(F - 2 * D)
                  - 0.055 * Degrees.Sin(Mm - F - 2 * D)
                  - 0.046 * Degrees.Sin(Mm + F - 2 * D)
                  + 0.033 * Degrees.Sin(F + 2 * D)
                  + 0.017 * Degrees.Sin(2 * Mm + F);

            dist = r
                   - 0.58 * Degrees.Cos(Mm - 2 * D)
                   - 0.46 * Degrees.Cos(2 * D);

            lon = Degrees.Normalize(lon);
            lat = Degrees.Normalize(lat);
        }
Example #24
0
 public ITStudent(string surname, string name, string middlename, Universities university, Degrees degree, DateTime dateOfBirth, Genders gender = Genders.Male, Educations education = Educations.HighSchool) : base(surname, name, middlename, university, degree, dateOfBirth, gender, education)
 {
     Marks               = new Subjects();
     SeccionMarks        = new List <int>();
     ProgrammingLanguges = 0;
 }
        // Sun Calculations

        static void ConvertRectangularToSpherical(double x, double y, double z, out double rasc, out double decl, out double dist)
        {
            dist = Math.Sqrt(x * x + y * y + z * z);
            rasc = Degrees.Atan2(y, x);
            decl = Degrees.Atan2(z, Math.Sqrt(x * x + y * y));
        }
Example #26
0
 /// <summary>
 /// Tests whether the specified <see cref="Rotation" /> is equivalent to this <see cref="Rotation" />.
 /// </summary>
 /// <param name="other">The rotation to test.</param>
 /// <returns><c>true</c> if <paramref name="other" /> is equivalent to this <see cref="Rotation" />; otherwise, <c>false</c>.</returns>
 public bool Equals(Rotation other) => Degrees.EqualsInTolerance(other.Degrees);
Example #27
0
 /// <summary>
 /// Get coordinates as a string. This string is always culture invariant.
 /// </summary>
 /// <returns>The angle as a culture invariant string</returns>
 public override string ToString()
 {
     return(Degrees.ToString(NumberFormatInfo.InvariantInfo));
 }
Example #28
0
 /// <summary>
 ///     Calculate a hash code for the angle.
 /// </summary>
 /// <returns>hash code</returns>
 public override int GetHashCode()
 {
     return(Degrees.GetHashCode());
 }
Example #29
0
 /// <summary>
 /// Gest the rate of turn for an object, using the bank angle and horizontal velocity.
 /// </summary>
 /// <returns>The rate of turn in degrees per second.</returns>
 protected virtual float getRateOfTurn()
 {
     return((float)(Math.Tan(Degrees.toRadians(bankAngle)) * 1091 / Common.convertToKNOTS(getHorizontalSpeed())));
 }
Example #30
0
 public Vector(ISpeed speed, Degrees direction)
 {
     this.speed = speed;
     this.direction = direction;
 }
Example #31
0
 public override string ToString() => Degrees.ToString("0.##°");