-
Set Target position of COM.
-
Calculate COM based on Volume of the object -->
MainBody
. -
Create copy of the object -->
MassBody
, which would be the mass component of the final object. -
Shrink the copied object with a factor,
shrink_factor
. -
Convert the
MassBody
to voxel grid. Each vertex representing a voxel. -
Starting with Axis 1 (
X
- Axis), based on the position of current COM and target COM, Vertex/Voxel (ofMassBody
) farthest from the current axis is removed, Removal of vertex is considered as removal of empty space or addition of mass. -
The
MassBody
is combined withMainBody
and the COM is calculated. -
With the updated COM, if the COM is within the
base_tolerance
, next Axis is selected. If the COM is not within thebase_tolerance
, next farthest Vertex/Voxel is removed until the COM is within thebase_tolerance
. -
Simultaneously, the convergence graph is plotted.
-
If the current COM cannot converge with the target COM for
convergence_buffer_size
iterations, Error is returned and next axis is selected assuming the solution is not possible and the COM (on that axis) just before the error is the best closest solution.