py3dframe.mirror_across_plane#
- mirror_across_plane(frame, normal, point, use_global=False, inplace=True)[source]#
Mirror a frame across a specified plane.
The frame is mirrored across the plane defined by a normal vector and a point on the plane.
If
use_globalis set to True, the mirroring is applied in the global coordinate system. Otherwise, the mirroring is applied in the local coordinate system of the frame (in the parent frame).
Warning
Mirroring a frame will change its handedness. If the original frame is right-handed, the mirrored frame will be left-handed, and vice versa. However
py3dframe.Frameonly supports right-handed frames. Therefore, after mirroring, the x-axis of the output frame is flipped to restore right-handedness.See also
py3dframe.Frame: for more information about the Frame class.py3dframe.translate(): to translate a frame by given offsets along each axis.py3dframe.rotate_around_axis(): to rotate a frame around a specific axis
- Parameters:
frame (Frame) – The frame to mirror.
normal (numpy.ndarray) – A 3D vector representing the normal of the plane across which to mirror the frame. The vector not need to be normalized.
point (numpy.ndarray) – A 3D point on the plane across which to mirror the frame.
use_global (bool, optional) – If True, the mirroring is applied in the global coordinate system. If False, the mirroring is applied in the local coordinate system of the frame. Default is False.
inplace (bool, optional) – If True, the mirroring is applied to the input frame and the same frame is returned. If False, a new mirrored frame is returned and the input frame remains unchanged. Default is True.
- Returns:
The mirrored frame (with x-axis flipped to restore right-handedness).
- Return type:
Examples
from py3dframe import Frame, mirror_across_plane import numpy as np # Create a default frame frame = Frame.canonical() # Define the normal of the plane (e.g., the xy-plane) normal = np.array([0.0, 0.0, 1.0]) point = np.array([0.0, 0.0, 0.0]) # A point on the plane # Mirror the frame across the specified plane in the local coordinate system mirrored_frame = mirror_across_plane(frame, normal, point, use_global=False, inplace=True) # The orientation of the mirrored frame is now changed print(mirrored_frame.orientation)