Calculating the Centroid Point of Geometry

A Centroid point is the center point of a certain geometrical shape. In Houdini the centroid of a geometry can be accessed using Houdini’s expression function $CEX $CEY $CEZ. This returns the centroid point and their respective X, Y, and Z values.

Therefore if you wanted to get the centroid point position:

( $CEX, $CEY, $CEZ )

The math calculation behind centroids is very similar to calculating the average. In order to calculate the centroid coordinate position value of a geometry we need to find a bounding area around the geometry, then we’ll know the minimum position and maximum position of the bounding box.

 

Average

Destruction Force Field___Math Vector___midpoint of line.JPG

When taking the average of two points on a line, the result will be the mid-point between the two points or the middle of the line. So you can imagine three lines on the X, Y, and Z axis of a box and taking the average of each axis line individually, which will return the average mid-point position on the X axis and mid-point position on the Y axis and the Z axis.

That’s what the $CEX $CEY $CEZ are returning.

 

Bounding Box

Destruction Force Field___Math Vector___bounding box of sphere.JPG

Let’s take a sphere for example, the bounding box around the sphere will be a box that covers the sphere entirely.

For example, in order to calculate the centroid of a geometry we first need to take the average of both the minimum and maximum points of the bounding box and we’ll get a mid-point returned.

 
Destruction Force Field___Math Vector___Line across bounding box.JPG

In order to illustrate this, I have drawn a line from two furthest corners of the bounding box and the red circle is the centroid point. If we take the average or find the mid-point of this yellow line it is returns the centroid point.

 
Destruction Force Field___Math Vector___Centroid Point of Bounding Box.JPG

On the screenshot on the right, the RED point in the middle is the Centroid point and there are two arrows pointing toward the centroid point. Each arrow has the same length. The two arrows is the line from one corner of the box to the furthest other corner of the box and where the arrow heads meet is the mid-point, which is the centroid point.

 

Bounding Box in Houdini

Destruction Force Field___Centroid___BOudning Box.jpg

In Houdini, if you drop down a attribute VOP node and go inside to drop another bound box node, you’ll realize that the bound box function has 2 output that get returned. A minimum point and a maximum point. This defines two from the box that are furthest apart.

 
Destruction_Force Field___Math Bounding_SOP context node.jpg

In the SOP level context of Houdini, you have a Bound node that you can use and it will find the bounding box that will fit right over the input geometry.