py3dframe.translate#

translate(frame, dx=0.0, dy=0.0, dz=0.0, use_global=False, inplace=True)[source]#

Translate a frame by a given offset along each axis.

The origin of the frame is moved by the specified offsets along the x, y, and z axes.

If use_global is set to True, the translation is applied in the global coordinate system. Otherwise, the translation is applied in the local coordinate system of the frame (in the parent frame).

\[\begin{split}\text{new_origin} = \text{origin} + \begin{bmatrix} dx \\ dy \\ dz \end{bmatrix}\end{split}\]

See also

Parameters:
  • frame (Frame) – The frame to translate.

  • dx (float, optional) – The translation along the x-axis. Default is 0.0.

  • dy (float, optional) – The translation along the y-axis. Default is 0.0.

  • dz (float, optional) – The translation along the z-axis. Default is 0.0.

  • use_global (bool, optional) – If True, the translation is applied in the global coordinate system. If False, the translation is applied in the local coordinate system of the frame. Default is False.

  • inplace (bool, optional) – If True, the translation is applied to the input frame and the same frame is returned. If False, a new translated frame is returned and the input frame remains unchanged. Default is True.

Returns:

The translated frame.

Return type:

Frame

Examples

from py3dframe import Frame
from py3dframe import translate

# Create a default frame
frame = Frame.canonical()

# Translate the frame by 1 unit along the x-axis, 2 units along the y-axis, and 3 units along the z-axis
translated_frame = translate(frame, dx=1.0, dy=2.0, dz=3.0, use_global=False, inplace=True)

# The origin of the translated frame is now at (1.0, 2.0, 3.0) in the local coordinate system
print(translated_frame.origin)  # Output: [1. 2. 3.]