public void Horizontal2EquatorialTest(double azimuth, double altitude, double latitude, double expectedX, double expectedY) { AAS2DCoordinate horizontal = AASCoordinateTransformation.Horizontal2Equatorial(azimuth, altitude, latitude); Assert.Equal(expectedX, horizontal.X); Assert.Equal(expectedY, horizontal.Y); }
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)); }
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 )); }
// converts horizontal coordinates to equitorial coordinates public static AAS2DCoordinate ToCelestialCoordinates(float lat, float lng, float az, float alt) { /* * Key: * ------------ Local Coordinates ------------- * az = azimuth - angle around the horizon from due north to under POI (north has azimuth of 0m south has azimuth of 180) * alt = altitude - angle from the horizon where the object is. * lat = latitude * long = Longitude * lst = local sideral time - Greenwich meridian plus Longitude * lha = local hour angle - It is the angle between the meridian of your Assumed Position and the meridian of the geographical position of the celestial body. * ------------ Equatorial Coordinates --------------- * ra = right ascention * dec = declination angle * ha = hour angle - angle between local meridian projected on celestial sphere, and right ascention of body * * * CALCULATING: 'right ascension' (ra) and 'declination' (dec) * 1) sin(alt) = sin(dec)sin(lat) + cos(dec)cos(lat)cos(ha) * 2) sin(ha) = tan(az)[cos(ha)sin(lat) - tan(dec)cos(lat)] * 3) ra = lst - ha * * Rearranging leads to: * ha = arctan(x,y) * x = sin(lat)cos(alt)cos(az) + cos(lat)sin(alt) * y = cos(alt)sin(az) * * dec = arctan(x', y') * x' = sin(az)cos(ha)sin(lat) - sin(ha)cos(az) * y' = cos(lat)sin(az) */ //find coordinates assuming sidereal_time is 00::00::00 AAS2DCoordinate converted = AASCoordinateTransformation.Horizontal2Equatorial(az, alt, lat); //adjust for local sideral_time converted.X += (LocalSiderealTime(lng) * (360f / 24f)); return(converted); }