Method for fitting a circe through a set of points

rhinocommon

#1

Hi,

I have been trying to locate the correct Method in Rhino.Common that attempts to fit a circle through a collection of points.

There is a method in Rhino.Geometry Sphere.Structure to do this
http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Sphere_FitSphereToPoints.htm

and I there is a command in Rhino and a component in GH to do the same for circles, but I just cant find how or where.

Many thanks!
Mathias


(Michael Pryor) #2

Fit Circle is a combination of Rhinocommon Sphere.FitSphereToPoints and Plane.FitPlaneToPoints. Then you intersect the plane and sphere.


Fit Circle.gh (5.7 KB)


#3

Thanks, Michael.

So this could look something like this

  Sphere S = Sphere.FitSphereToPoints(Pts);
  Plane Pl = new Plane();
  Plane.FitPlaneToPoints(Pts, out Pl);
  Circle C = new Circle();
  Rhino.Geometry.Intersect.Intersection.PlaneSphere(Pl, S, out C);

Or is there a more elegant way?


Co-circular constraint
(Dale Fugier) #4

Hi @mathias_gmachl,

I am not seeing a better way at this time.

https://mcneel.myjetbrains.com/youtrack/issue/RH-43626

– Dale


#5

Thanks @dale. I’ll keep an eye on it.


(Dale Fugier) #6

Hi @mathias_gmachl,

Looks like a new Rhino.Geometry.Circle.TryFitCircleToPoints static function will make it into SR2.

– Dale


#7

Thanks @dale !
This is now at least 10 times as fast and allows Kangaroo 2 to converge in seconds.


Co-circular constraint