public static void Main()
Console.WriteLine("Ptolemy's construction of a pentagon");
Console.WriteLine("Draw a regular pentagon inside the circle");
Point3d O = new Point3d(0, 0, 0);
Circle3d circle = new Circle3d(O, 1, new Vector3d(0, 0, 1));
Point3d C = circle.ParametricForm(0);
Line3d l = new Line3d(C, O);
Segment3d CD = (Segment3d)l.IntersectionWith(circle);
Circle3d circle1 = new Circle3d(C, CD.Length, circle.Normal);
Circle3d circle2 = new Circle3d(D, CD.Length, circle.Normal);
Line3d line = ((Segment3d)circle1.IntersectionWith(circle2)).ToLine;
Segment3d AB = (Segment3d)line.IntersectionWith(circle);
double radius = M.DistanceTo(C);
circle1 = new Circle3d(M, radius, circle.Normal);
Segment3d ON = (Segment3d)circle1.IntersectionWith(AB);
double side_len = C.DistanceTo(N);
circle1 = new Circle3d(C, side_len, circle.Normal);
Segment3d tmp_segment = (Segment3d)circle1.IntersectionWith(circle);
Point3d P2 = tmp_segment.P1;
Point3d P5 = tmp_segment.P2;
circle1 = new Circle3d(P2, side_len, circle.Normal);
tmp_segment = (Segment3d)circle1.IntersectionWith(circle);
Point3d P3 = tmp_segment.P1;
circle1 = new Circle3d(P3, side_len, circle.Normal);
tmp_segment = (Segment3d)circle1.IntersectionWith(circle);
Point3d P4 = tmp_segment.P1;
double angle1 = new Vector3d(P1, P2).AngleToDeg(new Vector3d(P1, P5));
double angle2 = new Vector3d(P2, P1).AngleToDeg(new Vector3d(P2, P3));
double angle3 = new Vector3d(P3, P2).AngleToDeg(new Vector3d(P3, P4));
double angle4 = new Vector3d(P4, P3).AngleToDeg(new Vector3d(P4, P5));
double angle5 = new Vector3d(P5, P4).AngleToDeg(new Vector3d(P5, P1));
if ( Math.Abs(angle1 - 108.0) < tolerance &&
Math.Abs(angle2 - 108.0) < tolerance &&
Math.Abs(angle3 - 108.0) < tolerance &&
Math.Abs(angle4 - 108.0) < tolerance &&
Math.Abs(angle5 - 108.0) < tolerance )
Console.WriteLine("Your construction is correct!");
Console.WriteLine(P1.ToString());
Console.WriteLine(P2.ToString());
Console.WriteLine(P3.ToString());
Console.WriteLine(P4.ToString());
Console.WriteLine(P5.ToString());