public static AAS2DCoordinate MoonPosition(DateTime dateTime) { dateTime = dateTime.ToUniversalTime(); // NOTE: time must be converted to Universal Time //Calculate the topocentric horizontal position of the Moon AASDate dateMoonCalc = new AASDate(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, true); double JDMoon = dateMoonCalc.Julian + AASDynamicalTime.DeltaT(dateMoonCalc.Julian) / 86400.0; double MoonLong = AASMoon.EclipticLongitude(JDMoon); double MoonLat = AASMoon.EclipticLatitude(JDMoon); AAS2DCoordinate Equatorial = AASCoordinateTransformation.Ecliptic2Equatorial(MoonLong, MoonLat, AASNutation.TrueObliquityOfEcliptic(JDMoon)); double MoonRad = AASMoon.RadiusVector(JDMoon); MoonRad /= 149597870.691; //Convert KM to AU AAS2DCoordinate MoonTopo = AASParallax.Equatorial2Topocentric(Equatorial.X, Equatorial.Y, MoonRad, RT_LONG, RT_LAT, RT_HEIGHT, JDMoon); double AST = AASSidereal.ApparentGreenwichSiderealTime(dateMoonCalc.Julian); double LongtitudeAsHourAngle = AASCoordinateTransformation.DegreesToHours(RT_LONG); double LocalHourAngle = AST - LongtitudeAsHourAngle - MoonTopo.X; AAS2DCoordinate MoonHorizontal = AASCoordinateTransformation.Equatorial2Horizontal(LocalHourAngle, MoonTopo.Y, RT_LAT); MoonHorizontal.Y += AASRefraction.RefractionFromTrue(MoonHorizontal.Y, 1013, 10); //The result above should be that we have a rising Moon at Y degrees above the horizon at azimuth X degrees east of the southern horizon //NOTE: for azimuth west is considered positive, to get east as positive subtract the result from 360 return(MoonHorizontal); }
public static AAS2DCoordinate SunPosition(DateTime dateTime) { var bHighPrecision = false; dateTime = dateTime.ToUniversalTime(); // NOTE: time must be converted to Universal Time //Calculate the topocentric horizontal position of the Sun AASDate dateSunCalc = new AASDate(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, true); double JDSun = dateSunCalc.Julian + AASDynamicalTime.DeltaT(dateSunCalc.Julian) / 86400.0; double SunLong = AASSun.ApparentEclipticLongitude(JDSun, bHighPrecision); double SunLat = AASSun.ApparentEclipticLatitude(JDSun, bHighPrecision); AAS2DCoordinate Equatorial = AASCoordinateTransformation.Ecliptic2Equatorial(SunLong, SunLat, AASNutation.TrueObliquityOfEcliptic(JDSun)); double SunRad = AASEarth.RadiusVector(JDSun, bHighPrecision); AAS2DCoordinate SunTopo = AASParallax.Equatorial2Topocentric(Equatorial.X, Equatorial.Y, SunRad, RT_LONG, RT_LAT, RT_HEIGHT, JDSun); double AST = AASSidereal.ApparentGreenwichSiderealTime(dateSunCalc.Julian); double LongtitudeAsHourAngle = AASCoordinateTransformation.DegreesToHours(RT_LONG); double LocalHourAngle = AST - LongtitudeAsHourAngle - SunTopo.X; AAS2DCoordinate SunHorizontal = AASCoordinateTransformation.Equatorial2Horizontal(LocalHourAngle, SunTopo.Y, RT_LAT); SunHorizontal.Y += AASRefraction.RefractionFromTrue(SunHorizontal.Y, 1013, 10); //The result above should be that we have a setting Sun at Y degrees above the horizon at azimuth X degrees south of the westerly horizon //NOTE: for azimuth west is considered positive, to get east as positive subtract the result from 360 return(SunHorizontal); }
public Coordinate OrientationToCoordinate(Orientation currHorizontal, DateTime datetime) { // We don't want to modify the current orientation, so we must create a new instance Orientation horizontal = (Orientation)currHorizontal.Clone(); if (horizontal == null) { throw new ArgumentException("Orientation cannot be null"); } // Since AASharp considers south zero, flip the orientation 180 degrees horizontal.Azimuth += 180; if (horizontal.Azimuth > 360) { horizontal.Azimuth -= 360; } AAS2DCoordinate equatorial = AASCoordinateTransformation.Horizontal2Equatorial(horizontal.Azimuth, horizontal.Elevation, Location.Latitude); AASDate date = new AASDate(datetime.Year, datetime.Month, datetime.Day, datetime.Hour, datetime.Minute, datetime.Second, true); double ApparentGreenwichSiderealTime = AASSidereal.ApparentGreenwichSiderealTime(date.Julian); double LongtitudeAsHourAngle = AASCoordinateTransformation.DegreesToHours(Location.Longitude); double RightAscension = ApparentGreenwichSiderealTime - LongtitudeAsHourAngle - equatorial.X; if (RightAscension < 0) { RightAscension += 24; } return(new Coordinate(RightAscension, equatorial.Y)); }
//hour angle of the aries point public double GetHourAngleOfAriesPoint(){ double theta0Apparent = AASSidereal.ApparentGreenwichSiderealTime (jd); //hour angle in hours double H = theta0Apparent - location.longitude/15d; return H; }
public EquatorialCoords Horizontal2Equatorial(double azimuth, double altitude){ AAS2DCoordinate coords = AASCoordinateTransformation.Horizontal2Equatorial (azimuth+180, altitude, location.latitude); //right ascension (alpha) = apparent sidereal time at Greenwich (theta) - Local hour angle (H) - observer's longitude (L, positive west, negative east from Greenwich) double theta0Apparent = AASSidereal.ApparentGreenwichSiderealTime (jd); double ra = theta0Apparent - coords.X - location.longitude / 15d; return new EquatorialCoords(new HourAngle(ra), new DegreesAngle( coords.Y )); }
public LocalCoords Equatorial2Horizontal(double ra, double dec){ double theta0Apparent = AASSidereal.ApparentGreenwichSiderealTime (jd); //hour angle in hours double H = theta0Apparent - location.longitude/15d - ra; AAS2DCoordinate localCoords = AASCoordinateTransformation.Equatorial2Horizontal (H, dec, location.latitude); double azimuth = AASCoordinateTransformation.MapTo0To360Range (localCoords.X + 180d); return new LocalCoords(new DegreesAngle(azimuth), new DegreesAngle(localCoords.Y)); }
public void ApparentGreenwichSiderealTime(int year, int month, int day, int hours, int minutes, int seconds, bool isGregorian, double expectedSideralTime) { var date = new AASDate(); date.Set(year, month, day, hours, minutes, seconds, isGregorian); var apparentGreenwichSiderealTime = AASSidereal.ApparentGreenwichSiderealTime(date.Julian); Assert.Equal(expectedSideralTime, apparentGreenwichSiderealTime); }
protected void CalculateTopocentricPosition() { double theta0Apparent = AASSidereal.ApparentGreenwichSiderealTime(jd); //hour angle in hours localHourAngle = theta0Apparent - location.longitude / 15d - equatorialCoords.RA.Get(); AAS2DCoordinate local = AASCoordinateTransformation.Equatorial2Horizontal(localHourAngle, equatorialCoords.Declination.Get(), location.latitude); localCoords.Azimuth = DegreesAngle.FromDecimalTo0To360Range(180.0f + local.X); localCoords.Altitude = new DegreesAngle(local.Y); }
/* * public LocalCoords LocalCoords(double jd, LocationData location){ * double theta0Apparent = AASSidereal.ApparentGreenwichSiderealTime (jd); * * //hour angle in hours * double H = theta0Apparent - location.longitude/15d - ra; * * AAS2DCoordinate localCoords = AASCoordinateTransformation.Equatorial2Horizontal (H, dec, location.latitude); * double azimuth = AASCoordinateTransformation.MapTo0To360Range (localCoords.X + 180d); * * return new LocalCoords(new DegreesAngle(azimuth), new DegreesAngle(localCoords.Y)); * }*/ public Vector3 GetLocalRectangularCoordinates(double jd, LocationData location) { double theta0Apparent = AASSidereal.ApparentGreenwichSiderealTime(jd); //hour angle in hours double H = theta0Apparent - location.longitude / 15d - this.ra; AAS2DCoordinate local = AASCoordinateTransformation.Equatorial2Horizontal(H, this.dec, location.latitude); double az = local.X; double alt = local.Y; double x = Math.Cos(alt * M.DEG2RAD) * Math.Sin(az * 15.0f * M.DEG2RAD); double y = Math.Sin(alt * M.DEG2RAD); double z = -Math.Cos(alt * M.DEG2RAD) * Math.Cos(az * 15.0f * M.DEG2RAD); return(new Vector3((float)x, (float)y, (float)z)); }
public Orientation CoordinateToOrientation(Coordinate coordinate, DateTime datetime) { if (coordinate == null) { throw new ArgumentException("Coordinate cannot be null"); } AASDate date = new AASDate(datetime.Year, datetime.Month, datetime.Day, datetime.Hour, datetime.Minute, datetime.Second, true); double ApparentGreenwichSiderealTime = AASSidereal.ApparentGreenwichSiderealTime(date.Julian); double LongtitudeAsHourAngle = AASCoordinateTransformation.DegreesToHours(Location.Longitude); double LocalHourAngle = ApparentGreenwichSiderealTime - LongtitudeAsHourAngle - coordinate.RightAscension; AAS2DCoordinate Horizontal = AASCoordinateTransformation.Equatorial2Horizontal(LocalHourAngle, coordinate.Declination, Location.Latitude); // Since AASharp considers south zero, flip the orientation 180 degrees Horizontal.X += 180; if (Horizontal.X > 360) { Horizontal.X -= 360; } return(new Orientation(Horizontal.X, Horizontal.Y)); }