Does anyone have a solution to finding a 'best fit' plane through a set of 3D points?
I do realise that 'best fit' is a rather ill defined requirement, but it's not critical for the project I'm thinking of.
Finding a 'best fit' plane through a set of 3D points
3090 12 4- Mike_A
- Member
- 271 posts
- Joined: Aug. 2018
- Offline
- CYTE
- Member
- 708 posts
- Joined: Feb. 2017
- Offline
- tamte
- Member
- 8785 posts
- Joined: July 2007
- Offline
- animatrix_
- Member
- 4693 posts
- Joined: Feb. 2012
- Offline
Here is one way using PCA (Principal Component Analysis):
Attrib Promote (P) = Point -> Detail | Average
Compute sum (Point Wrangle):
Compute PCA (Detail Wrangle):
Attrib Promote (P) = Point -> Detail | Average
Compute sum (Point Wrangle):
vector centroid = detail ( 0, "centroid" ); vector p = v@P - centroid; setdetailattrib ( geoself ( ), "sumxx", p.x * p.x, "add" ); setdetailattrib ( geoself ( ), "sumxy", p.x * p.y, "add" ); setdetailattrib ( geoself ( ), "sumxz", p.x * p.z, "add" ); setdetailattrib ( geoself ( ), "sumyy", p.y * p.y, "add" ); setdetailattrib ( geoself ( ), "sumyz", p.y * p.z, "add" ); setdetailattrib ( geoself ( ), "sumzz", p.z * p.z, "add" );
Compute PCA (Detail Wrangle):
matrix3 m = set ( @opinput1_sumxx, @opinput1_sumxy, @opinput1_sumxz, @opinput1_sumxy, @opinput1_sumyy, @opinput1_sumyz, @opinput1_sumxz, @opinput1_sumyz, @opinput1_sumzz ); matrix3 u = 0; vector s = 0; matrix3 v = 0; svddecomp ( m, u, s, v ); v = transpose ( v ); vector x = set ( v.xx, v.xy, v.xz ); vector y = set ( v.yx, v.yy, v.yz ); vector z = set ( v.zx, v.zy, v.zz ); vector centroid = v@opinput1_centroid; int pt = addpoint ( geoself ( ), centroid ); setpointattrib ( geoself ( ), "x", pt, x ); setpointattrib ( geoself ( ), "y", pt, y ); setpointattrib ( geoself ( ), "z", pt, z ); setpointattrib ( geoself ( ), "N", pt, z );
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- Mike_A
- Member
- 271 posts
- Joined: Aug. 2018
- Offline
- Mike_A
- Member
- 271 posts
- Joined: Aug. 2018
- Offline
https://www.orbolt.com/asset/animatrix::bestFitPlane::1.00
That would be really good to have as a HDA - but unfortunately it doesn't seem to work in 19.5 - unless I'm missing something.
If there is a possibility of an updated version I would be very appreciative, but do understand that delivering such is work...
That would be really good to have as a HDA - but unfortunately it doesn't seem to work in 19.5 - unless I'm missing something.
If there is a possibility of an updated version I would be very appreciative, but do understand that delivering such is work...
- animatrix_
- Member
- 4693 posts
- Joined: Feb. 2012
- Offline
Mike_A
https://www.orbolt.com/asset/animatrix::bestFitPlane::1.00
That would be really good to have as a HDA - but unfortunately it doesn't seem to work in 19.5 - unless I'm missing something.
If there is a possibility of an updated version I would be very appreciative, but do understand that delivering such is work...
This is a very old OTL. Many things changed in VEX since then.
The above method I posted is superior. So you can turn that into an HDA if you wanted.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- Mike_A
- Member
- 271 posts
- Joined: Aug. 2018
- Offline
- CYTE
- Member
- 708 posts
- Joined: Feb. 2017
- Offline
- animatrix_
- Member
- 4693 posts
- Joined: Feb. 2012
- Offline
Yes it still works. Are you sure you set grid geometry to XY Plane orientation before copying?
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- Konstantin Magnus
- Member
- 682 posts
- Joined: Sept. 2013
- Offline
I've just published an example file with animatrix' code here:
https://procegen.konstantinmagnus.de/fitting-planes-to-point-clouds [procegen.konstantinmagnus.de]
https://procegen.konstantinmagnus.de/fitting-planes-to-point-clouds [procegen.konstantinmagnus.de]
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
- vinyvince
- Member
- 275 posts
- Joined: Sept. 2012
- Offline
I have probably missed something with svddecomp , everytime i struggle with one direction which looks off to me..
So if i take your version, i get the reduction red plane, doesn't look that correct not?
I could improve the result with some "prefiltering", which give me the blue plane , way better already...
Have you also noticed or is it me only?
So if i take your version, i get the reduction red plane, doesn't look that correct not?
I could improve the result with some "prefiltering", which give me the blue plane , way better already...
Have you also noticed or is it me only?
Vincent Thomas (VFX and Art since 1998)
Senior Env and Lighting artist & Houdini generalist & Creative Concepts
http://fr.linkedin.com/in/vincentthomas [fr.linkedin.com]
Senior Env and Lighting artist & Houdini generalist & Creative Concepts
http://fr.linkedin.com/in/vincentthomas [fr.linkedin.com]
- CYTE
- Member
- 708 posts
- Joined: Feb. 2017
- Offline
-
- Quick Links