static public Vector2DD EquitorialToHorizon(Vector2DD equitorial, Vector2DD location, double jDate) { double hourAngle = MstFromUTC2(jDate, location.X) - (equitorial.X * 15); if (hourAngle < 0) { hourAngle += 360.00; } double ha = hourAngle * RC; double dec = equitorial.Y * RC; double lat = (location.Y) * RC; double sinAlt = Math.Sin(dec) * Math.Sin(lat) + Math.Cos(dec) * Math.Cos(lat) * Math.Cos(ha); double altitude = Math.Asin(sinAlt); double cosAzimith = (Math.Sin(dec) - Math.Sin(altitude) * Math.Sin(lat)) / (Math.Cos(altitude) * Math.Cos(lat)); double azimuth = Math.Acos(cosAzimith); Vector2DD altAz = new Vector2DD(azimuth/RC, altitude/RC); if (Math.Sin(ha) > 0) { altAz.X = (360 - altAz.X); } return altAz; }
public Bitmap GetChart(double lat, double lng, double time, double ra, double dec, int width, int height) { double radius = width/2; Vector2DD location = new Vector2DD(lng,lat); Bitmap bmp = new Bitmap(width, height); Graphics g = Graphics.FromImage(bmp); g.Clear(Color.White); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; //g.DrawEllipse(Pens.Black, ); SolidBrush black = new SolidBrush(Color.Black); SolidBrush white = new SolidBrush(Color.White); g.FillEllipse(black, new RectangleF(0, 0, (float)(radius * 2), (float)(radius * 2))); // draw stars for (int i = 0; i < stars.Length ; i+=3 ) { Vector2DD pnt = new Vector2DD(stars[i]/15, stars[i + 1]); Vector2DD pntOut = Calc.EquitorialToHorizon(pnt, location, time); pntOut.X -= 90; double mag = stars[i + 2]; double x = radius - Math.Cos(pntOut.X * Calc.RC) * ((1 - pntOut.Y / 90) * radius); double y = radius + Math.Sin(pntOut.X * Calc.RC) * ((1 - pntOut.Y / 90) * radius); double size = (6-mag)*4/5; //size = 5; g.FillEllipse(white, new RectangleF((float)(x-(size/2)), (float)(y-(size/2)), (float)size, (float)size)); } // draw constellation lines double lastX = 0; double lastY = 0; bool first = true; for (int i = 0; i < figures.Length ; i+=3 ) { Vector2DD pnt = new Vector2DD(figures[i] , figures[i + 1]); Vector2DD pntOut = Calc.EquitorialToHorizon(pnt, location, time); pntOut.X -= 90; double x = radius - Math.Cos(pntOut.X * Calc.RC) * ((1 - pntOut.Y / 90) * radius); double y = radius + Math.Sin(pntOut.X * Calc.RC) * ((1 - pntOut.Y / 90) * radius); if (figures[i + 2] == 0 || first) { first = false; } else { if (pntOut.Y > -20) { g.DrawLine(Pens.White, new PointF((float)x, (float)y), new PointF((float)lastX, (float)lastY)); } } lastX = x; lastY = y; } // draw ecliptic // draw planets / moon // draw labels // draw target //return bitmap //Clean up black.Dispose(); white.Dispose(); g.Flush(); g.Dispose(); return bmp; }