def rotate_all_in_world( self, rotation: tp.Union[Matrix3, Vector3, list, tuple, int, float], pivot_point=(0, 0, 0), radians=False, selected_entries=(), ): """Rotate every Part and Region in the map around the given `pivot_point` by the Euler angles specified by `rotation`, modifying both `.rotate` and (unless equal to `pivot_point`) `.translate` for each entry. Args: rotation: Euler angles, as specified by `(x, y, z)`, an Euler rotation matrix, or a single value to apply simple `y` rotation only. pivot_point: point around with `rotation` will be applied. Defaults to world origin, `(0, 0, 0)`. radians: if True, given `rotation` is in radians; degrees otherwise. Defaults to `False` (degrees). selected_entries: if not empty, move only these given entries. Each element in this sequence can be an `MSBEntry` instance or the name (if unique) of a Part or Region. """ selected_entries = self.resolve_entries_list(selected_entries, entry_types=("parts", "regions")) rotation = resolve_rotation(rotation) pivot_point = Vector3(pivot_point) for part in self.parts: if not selected_entries or part in selected_entries: part.apply_rotation(rotation, pivot_point=pivot_point, radians=radians) for region in self.regions: if not selected_entries or region in selected_entries: region.apply_rotation(rotation, pivot_point=pivot_point, radians=radians)
def apply_rotation( self, rotation: tp.Union[Matrix3, Vector3, list, tuple, int, float], pivot_point=(0, 0, 0), radians=False, ): """Modify entity `translate` and `rotate` by rotating entity around some `pivot_point` in world coordinates. Default `pivot_point` is the world origin (0, 0, 0). Default rotation units are degrees. """ rotation = resolve_rotation(rotation, radians) pivot_point = Vector3(pivot_point) self._rotate = (rotation @ Matrix3.from_euler_angles(self.rotate)).to_euler_angles() self._translate = (rotation @ (self.translate - pivot_point)) + pivot_point