solid.Shape

Methods

Method Reference: solid.Shape.centroid

solid.Shape: C = centroid (S)

solid.Shape: C = centroid (S, 'RelTol', TOL)

The centre of volume of a shape, as a 1-by-3 vector in millimetres.

For a part of uniform density this is its centre of mass, computed as the volume is, 'RelTol' included. The empty shape has no centroid and returns an empty C, and a shape that encloses no volume returns NaN in every coordinate.

The centre takes far longer to integrate than the volume: a second or more on a sphere, a cone or a torus, and a minute or more on the spline surfaces of a shape made by solid.surface, where a looser 'RelTol' saves little.

 
 ## An L-shaped bracket balances off its corner
 L = union (solid.box (30, 10, 5), solid.box (5, 10, 20));
 centroid (L)
 ⇒ 10.8333    5.0000    5.8333

See also: solid.Shape.volume, solid.Shape.bbox

Source Code: solid.Shape