hdk group centroid position

   4817   3   1
User Avatar
Member
3 posts
Joined: 8月 2007
Offline
hi
i'm learning hdk and don't know how to get the centroid position of a group in hdk?
is there any function to get the central point position for the input group or is there any way/ways to get the central point position?
Thanks
User Avatar
Member
31 posts
Joined: 7月 2005
Offline
I don't know if there's a function that does this for you (might want to look at UT_BoundingBox). I did it the old fashion way:


FOR_ALL_GPOINTS(gdp, ppt)
{
UT_Vector4 pos4=ppt->getPos();

txSum+=pos4.x()/pos4.w();
tySum+=pos4.y()/pos4.w();
tzSum+=pos4.z()/pos4.w();
}

myCEX=txSum/myTotalPoints;
myCEY=tySum/myTotalPoints;
myCEZ=tzSum/myTotalPoints;

hope that helps
Luca
User Avatar
Member
3 posts
Joined: 8月 2007
Offline
thanx.
i'll give it a try.
User Avatar
Member
7899 posts
Joined: 7月 2005
Offline
There's also the GEO_Detail::getPointBBox() function. Then you can just call bbox->center().
  • Quick Links