Find best-fit circle (automatically)

   338   4   0
User Avatar
Member
82 posts
Joined: Jan. 2015
Offline
I have a slightly uneven poly circle. Is there a way to automatically (not manually) find the best-fit circle, i.e. one that minimizes the sum of distances from the poly? It's like finding a "best fit plane" for near-planar points, but for a circle. There's a "Fit Curve" SOP, but it seems to create a very close NURBS approximation of the shape, not a perfect circle.
Edited by element33 - Dec. 30, 2024 00:44:23
User Avatar
Staff
534 posts
Joined: Aug. 2019
Offline
Is this circle 2-dimensional or 3-dimensional?
User Avatar
Member
82 posts
Joined: Jan. 2015
Offline
johnmather
Is this circle 2-dimensional or 3-dimensional?
2-D on the XZ plane
User Avatar
Staff
534 posts
Joined: Aug. 2019
Offline
In that case, you can approximate the result algebraically by performing something like this: https://scipy-cookbook.readthedocs.io/items/Least_Squares_Circle.html#Using-an-algebraic-approximation [scipy-cookbook.readthedocs.io]

I've attached a hip file that should do what you want. If you scrub the timeline, you'll be able to see the results for different inputs.

Attachments:
fit.png (45.5 KB)
circlefit.hip (213.0 KB)

User Avatar
Member
82 posts
Joined: Jan. 2015
Offline
johnmather
In that case, you can approximate the result algebraically
Excellent, works great. Fortunately, my poly is static, it doesn't rotate or change shape
  • Quick Links