MCPcopy
hub / github.com/CadQuery/cadquery / centerOfMass

Method centerOfMass

cadquery/occ_impl/shapes.py:831–847  ·  view source on GitHub ↗

Calculates the center of 'mass' of an object. :param obj: Compute the center of mass of this object

(obj: Shape)

Source from the content-addressed store, hash-verified

829
830 @staticmethod
831 def centerOfMass(obj: Shape) -> Vector:
832 """
833 Calculates the center of 'mass' of an object.
834
835 :param obj: Compute the center of mass of this object
836 """
837
838 if obj.ShapeType() == "Vertex":
839 geom_point = BRep_Tool.Pnt_s(tcast(TopoDS_Vertex, downcast(obj.wrapped)))
840 return Vector(geom_point.X(), geom_point.Y(), geom_point.Z())
841
842 Properties = GProp_GProps()
843 calc_function = Shape._mass_calc_function(obj)
844
845 calc_function(obj.wrapped, Properties)
846
847 return Vector(Properties.CentreOfMass())
848
849 @staticmethod
850 def CombinedCenterOfBoundBox(objects: list[Shape]) -> Vector:

Callers 2

CenterMethod · 0.80
CombinedCenterMethod · 0.80

Calls 4

downcastFunction · 0.85
VectorClass · 0.85
_mass_calc_functionMethod · 0.80
ShapeTypeMethod · 0.45

Tested by

no test coverage detected