public APoint ToPoint(APoint3D p) { var cos2 = Math.Sqrt(1.0 - p.Y * p.Y); var theta1 = -Math.Acos(p.X / cos2); if (p.Z > 0) theta1 += Math.PI; if (p.Z <= 0 && p.X > 0) theta1 -= Math.PI * 2; var cx = (((theta1 - 0.5 * Math.PI) * __Width) / Math.PI + __Width) / 2.0; if (p.Z <= 0 && p.X > 0) cx = Math.Abs(cx); double ly = 0.0; ly = (1.0 + ly) / (1.0 - ly); ly = 0.5 * Math.Log(ly); var k = (int)(0.5 * ly * __Width / Math.PI); ly = Math.Abs((p.Y + 1) / (p.Y - 1)); ly = Math.Abs(Math.Log(ly) / 2); if (p.Y > 0) ly *= -1; var cy = __Width - (ly * __Width / Math.PI + __height) / 2.0 + k; return APoint.Round(Math.Abs(cx), cy); }
public static APoint3D MiddlePoint(APoint3D p1, APoint3D p2) { return (p1 + p2) * 0.5f; }