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

Method CombinedCenterOfBoundBox

cadquery/occ_impl/shapes.py:850–866  ·  view source on GitHub ↗

Calculates the center of a bounding box of multiple objects. :param objects: A list of objects

(objects: list[Shape])

Source from the content-addressed store, hash-verified

848
849 @staticmethod
850 def CombinedCenterOfBoundBox(objects: list[Shape]) -> Vector:
851 """
852 Calculates the center of a bounding box of multiple objects.
853
854 :param objects: A list of objects
855 """
856 total_mass = len(objects)
857
858 weighted_centers = []
859 for o in objects:
860 weighted_centers.append(BoundBox._fromTopoDS(o.wrapped).center)
861
862 sum_wc = weighted_centers[0]
863 for wc in weighted_centers[1:]:
864 sum_wc = sum_wc.add(wc)
865
866 return Vector(sum_wc.multiply(1.0 / total_mass))
867
868 def Closed(self) -> bool:
869 """

Callers 1

workplaneMethod · 0.80

Calls 5

VectorClass · 0.85
appendMethod · 0.80
_fromTopoDSMethod · 0.80
addMethod · 0.45
multiplyMethod · 0.45

Tested by

no test coverage detected