/// <summary> /// Normal. Calculate the Cartesian normal vector /// corresponding to the PointEq p(ra,dec). /// </summary> /// <param name="p">PointEq object</param> /// <returns>Array of 3 doubles, a 3-vector</returns> public static double[] Normal(PointEq p) { double[] n = new double[3]; n[0] = Math.Cos(D2R * p.dec) * Math.Cos(D2R * p.ra); n[1] = Math.Cos(D2R * p.dec) * Math.Sin(D2R * p.ra); n[2] = Math.Sin(D2R * p.dec); return(n); }
/// <summary> /// ScreenToEq. Maps a screen coordinate to an (ra,dec). /// This is the inverse coordinate transformation function /// </summary> /// <param name="p">The screen coordinate of the point</param> public PointEq ScreenToEq(PointF p) { double[] r = new Double[3]; //---------------------------------------- // first subtract the offset, and rescale //---------------------------------------- PointF q = new PointF((float)((cOffset.X - p.X) / scale), (float)((cOffset.Y - p.Y) / scale)); //------------------------------------------------ // now these are the dot products with w and u // compute the dot product with the normal vector //------------------------------------------------ double qdec = 90 * q.Y; double qra = 180 + 180 * q.X * Math.Cos(qdec * V3.D2R); PointEq g = new PointEq(qra, qdec); return(g); }
/// <summary> /// ScreenToEq. Maps a screen coordinate to an (ra,dec). /// This is the inverse coordinate transformation function /// </summary> /// <param name="p">The screen coordinate of the point</param> public PointEq ScreenToEq(PointF p) { double[] r = new Double[3]; //---------------------------------------- // first subtract the offset, and rescale //---------------------------------------- PointF q = new PointF((float)((cOffset.X - p.X) / scale), (float)((cOffset.Y - p.Y) / scale)); //------------------------------------------------ // now these are the dot products with w and u // compute the dot product with the normal vector //------------------------------------------------ double gn = 1.0 - q.X * q.X - q.Y * q.Y; gn = Math.Sqrt(gn); for (int i = 0; i < 3; i++) { r[i] = gn * n[i] + q.X * w[i] + q.Y * u[i]; } PointEq g = V3.ToEq(r); return(g); }
/// <summary> /// ToEq. Calculate the Equatorial point corresponding to /// a Cartesian normal vector (x,y,z). /// </summary> /// <param name="x_">Cartesian x</param> /// <param name="y_">Cartesian y</param> /// <param name="z_">Cartesian z</param> /// <returns>Array of 2 doubles, a 2-vector</returns> public static PointEq ToEq(double[] r) { double _dec = Math.Asin(r[2]) / D2R; double _ra = 0.0; // catch r[0]=r[1]=0 case, the north/south pole if (Math.Abs(r[0]) < 1.0E-9 && Math.Abs(r[1]) < 1.0E-9) { _dec = 90.0 * r[2]; } else { _ra = Math.Atan2(r[1], r[0]) / D2R; if (_ra < 0) { _ra += 360.0; } } PointEq p = new PointEq(_ra, _dec); return(p); }
public PointF EqToScreen(PointEq e, float size_) { return(EqToScreen(e.ra, e.dec, size_)); }