Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Best fit plane
kdee122
Member, csevp Posts: 2 PRO
Best Answer
-
kdee122 Member, csevp Posts: 2 PROJed_Yeiser said:@kdee122 this is possible with featurescript, though a better understanding of what you mean by 'best fit' would be helpful. I wrote this featurescript quickly as a guide.
https://cad.onshape.com/documents/e07586cc7fffdd615af9086d/w/32107f51e26ed66715308556/e/a89ed3bf1988fac1cb746969?renderMode=0&uiState=6674ee6a607f8261b36ef812
This is exactly what i needed!!!! jed thanks for the feature script and I will take a look at the code, made it sound like it was a easy featurescript to write. I need to learn to make or at least modify feature scripts.1
Answers
https://cad.onshape.com/documents/e07586cc7fffdd615af9086d/w/32107f51e26ed66715308556/e/a89ed3bf1988fac1cb746969?renderMode=0&uiState=6674ee6a607f8261b36ef812
This is exactly what i needed!!!! jed thanks for the feature script and I will take a look at the code, made it sound like it was a easy featurescript to write. I need to learn to make or at least modify feature scripts.
All of this said, I can't think of an application where I would WANT to use a plane defined like this. Good luck!
Thank you, that is absolutely what I needed.
I use it as an integral part of building a Part Studio around a 3D scan.
The cloud points are precise, but still slightly imperfect. Using your script, I was able to choose many points and get the absolute best fit. This was a huge time savings and quality improvement from my prior process: choosing a three point plane and then having to go back and deselect/select individual points until I felt I had achieved best fit.
The only thing I wish could be different about using BFPfP is to be able to still see the points when I click "Final". (They all disappear from view, as in the below screenshot)
=================================================
One note of caution is that the LSQ approach to minimizing
z
distance is perhaps suboptimal for the problem. It works well, but a more perfect solution would be to minimize perpendicular distance. This would be more robust when the user is working with points which have little x-y variance.I'm not super familiar with FS, but here's the Matlab code to find the plane which minimizes the perpendicular distance of the points from the plane:
UPDAET: thanks to @Jed_Yeiser's script I was able to modify my code to use SVD. I published it to the Custom FS list, please let me know if there's any feedback or feature requests.
https://cad.onshape.com/documents/3214428d3d799be304e66fd9/w/83efbb2135152269c6209e10/e/90d14bf609df1d8351b029a5
(In a v2, it would be interesting to try using RANSAC, as in https://math.stackexchange.com/a/4574602/222880.)
OMG. Thank you for this…
@kenn_sebesta167 @Jed_Yeiser
. Something I've been searching for. This will help so much with ocd of trying to match up with import scans at least for flat areas.. Now if we can get something similar for non planer surfaces…we'll be cookin'!!