Calculates the center of mass of multiple objects. :param objects: A list of objects with mass
(objects: Iterable[Shape])
| 767 | |
| 768 | @staticmethod |
| 769 | def CombinedCenter(objects: Iterable[Shape]) -> Vector: |
| 770 | """ |
| 771 | Calculates the center of mass of multiple objects. |
| 772 | |
| 773 | :param objects: A list of objects with mass |
| 774 | """ |
| 775 | total_mass = sum(Shape.computeMass(o) for o in objects) |
| 776 | weighted_centers = [ |
| 777 | Shape.centerOfMass(o).multiply(Shape.computeMass(o)) for o in objects |
| 778 | ] |
| 779 | |
| 780 | sum_wc = weighted_centers[0] |
| 781 | for wc in weighted_centers[1:]: |
| 782 | sum_wc = sum_wc.add(wc) |
| 783 | |
| 784 | return Vector(sum_wc.multiply(1.0 / total_mass)) |
| 785 | |
| 786 | @staticmethod |
| 787 | def _mass_calc_function(obj: Shape) -> Any: |