/// <summary> /// Initializes an circle from three points. /// https://github.com/sergarrido/random/tree/master/circle3d /// </summary> /// <param name="pt1">Start point of the arc.</param> /// <param name="pt2">Interior point on arc.</param> /// <param name="pt3">End point of the arc.</param> public Circle(Point3 pt1, Point3 pt2, Point3 pt3) { if (!pt1.IsValid) { throw new Exception("The first point is not valid."); } if (!pt2.IsValid) { throw new Exception("The second point is not valid."); } if (!pt3.IsValid) { throw new Exception("The third point is not valid."); } Point3 center = Trigonometry.EquidistantPoint(pt1, pt2, pt3); Vector3 normal = Vector3.ZAxis.PerpendicularTo(pt1, pt2, pt3); Vector3 xDir = pt1 - center; Vector3 yDir = Vector3.CrossProduct(normal, xDir); Plane = new Plane(center, xDir, yDir); Radius = xDir.Length; _length = Math.Abs(2.0 * Math.PI * Radius); ToNurbs(); }