public HorizontalCoords ToHorizontal(Location loc, double T) { HorizontalCoords coordsout = new HorizontalCoords(); double theta = Utils.deg2rad(280.46061837 + (360.98564736629 * T * 36525) + (0.000387933 * T * T) - ((T * T * T) / 38710000)); double HA = theta - loc.lon - this.ra; coordsout.az = Math.Atan2(Math.Sin(HA), Math.Cos(HA) * Math.Sin(loc.lat) - Math.Tan(this.dec) * Math.Cos(loc.lat)) + Math.PI; coordsout.alt = Math.Asin(Math.Sin(loc.lat) * Math.Sin(this.dec) + Math.Cos(loc.lat) * Math.Cos(this.dec) * Math.Cos(HA)); return(coordsout); }
//Convert Alt/Az to RA/Dec. Input and output in rads public static EquatorialCoords HorizontalToEquatorial(HorizontalCoords coords, Location loc, double T) { EquatorialCoords coordsout = new EquatorialCoords(); double HA = Math.Atan2(Math.Sin(coords.az + Math.PI), Math.Cos(coords.az + Math.PI) * Math.Sin(loc.lat) + Math.Tan(coords.alt) * Math.Cos(loc.lat)); double theta = deg2rad(280.46061837 + (360.98564736629 * T * 36525) + (0.000387933 * T * T) - ((T * T * T) / 38710000)); coordsout.ra = theta - loc.lon - HA; coordsout.dec = Math.Asin(Math.Sin(loc.lat) * Math.Sin(coords.alt) - Math.Cos(loc.lat) * Math.Cos(coords.alt) * Math.Cos(coords.az + Math.PI)); return(coordsout); }