phossystems / Reverse

Reconstructs BRep Surfaces from mesh points.
The Unlicense
36 stars 3 forks source link

Added some new routines for fitting an infinite cylinder to a set of 3D points #1

Closed DayBlur closed 4 years ago

DayBlur commented 4 years ago

Added some new routines for fitting an infinite cylinder to a set of 3D points

This was a fun exercise. I tried to include comments to help explain what's going on, but reach out if you have any questions. I didn't test it on a ton of inputs, but it seems to work well on 5 or more reasonably-selected points. Robustness checking could/should be added (check number of points, check if all points are in a plane, check residual fit metric, etc).

There might be a direct solution for the 3D case, but I could only derive the 2D case in a reasonable amount of time. Luckily, that left only two bounded parameters to iterate over which is a pretty cool outcome. I came up with this solution approach on my own, but this is probably a "solved" problem which may have a known-best method out there. Let me know if you come across something significantly different/better.