VEX Primitive @P vs Getbbox_center?

   7587   4   0
User Avatar
Member
527 posts
Joined: 7月 2005
Offline
If one wanted the centroid of a primitive what would be the better way to do so?

They both seem to give similar results but perhaps I am not looking at it the right way? Any insight would be greatly appreciated!
soho vfx
User Avatar
Member
355 posts
Joined: 11月 2015
Offline
I would think even though in primitive vex @P seems to give centroid, you're still manipulating points, so if you alter @P value the points of your geo will be repositioned which might throw off @P results if it's using some primitive averaging to give a center of geo position. The getbbox_center gives you the center of the geometry's bounding box which I would think is the better way to get the center.

Not sure if I'm 100% correct about the @P in primitive vex but it seems that's the way it works to me, maybe someone else can confirm or deny.
hou.f*ckatdskmaya().forever()
User Avatar
Member
17 posts
Joined: 3月 2015
Offline
According to documentation getbbox_center() [www.sidefx.com] gives You center of bounding box for the whole geometry, not for a single primitive.

Beside that, even if You want to run getbbox_center() over every primitive it will give You center of the bounding box (the smallest box aligned to XYZ axis that contain all given geometry).

v@P will give You average position of primitive points - this is often good enough and it's literally just 3 characters to write.

I might get a little bit tricky for concave primitives or for triangles with angle greater than 90 degrees - both methods will give You points “outside” of their surface, so if You want something more accurate You will have to try something more sophisticated.

Attachments:
average_position_vs_bbox.hipnc (79.6 KB)

User Avatar
Member
2042 posts
Joined: 9月 2015
Offline
According to documentation getbbox_center() gives You center of bounding box for the whole geometry, not for a single primitive.

You can if you group the desired primitive/s and give that to the second argument of the getbbox_center() function.

Beside that, even if You want to run getbbox_center() over every primitive it will give You center of the bounding box (the smallest box aligned to XYZ axis that contain all given geometry).

And, in the case of a single polygon face, it doesn't matter how it's oriented or situated in world space, you will get the exact center of that polygon.( on the polygons face )
Edited by BabaJ - 2018年3月27日 09:06:28
User Avatar
Member
527 posts
Joined: 7月 2005
Offline
It sounds like the getbbox_center is more precise but the @P gives a nice weighted result. If the points are somewhat evenly distributed the @P will prevent one weird point from swaying the result too much. However if the points are lopsided in the wrong way one could definitely get an inaccurate center.
soho vfx
  • Quick Links