py3dframe.Frame.from_axes#

classmethod Frame.from_axes(origin=None, x_axis=None, y_axis=None, z_axis=None, *, parent=None, setup_only=False, convention=0)[source]#

Create a Frame object from the given axes (origin and basis vectors).

See also

  • from_rotation() method to create a Frame from a rotation and a translation instead of its axes.

  • from_rotation_matrix() method to create a Frame from a rotation matrix and a translation instead of its axes.

  • from_quaternion() method to create a Frame from a quaternion and a translation instead of its axes.

  • from_euler_angles() method to create a Frame from euler angles and a translation instead of its axes.

  • from_rotation_vector() method to create a Frame from a rotation vector and a translation instead of its axes.

Parameters:
  • origin (array_like, optional) – The coordinates of the origin of the frame in the parent frame coordinates. Default is None - the zero vector.

  • x_axis (array_like, optional) – The x-axis of the frame in the parent frame coordinates. Default is None - the [1, 0, 0] vector.

  • y_axis (array_like, optional) – The y-axis of the frame in the parent frame coordinates. Default is None - the [0, 1, 0] vector.

  • z_axis (array_like, optional) – The z-axis of the frame in the parent frame coordinates. Default is None - the [0, 0, 1] vector.

  • parent (Optional[Frame], optional) – The parent frame of the frame. Default is None - the global frame.

  • setup_only (bool, optional) – If True, the parent frame will be used only to define the frame and not to link the frames. Default is False.

  • convention (int, optional) – Integer in [0, 7] selecting the convention to express the transformation. Default is 0.

Returns:

The Frame object created from the given axes.

Return type:

Frame

Examples

Lets create a frame from a given origin and basis vectors.

We want to create the frame defined by the following origin and basis vectors in the parent frame coordinates:

  • Origin: \(O_F = [-1, -2, -3]\)

  • X-axis: \(\mathbf{e}_1 = [1, 1, 0] / \sqrt{2}\)

  • Y-axis: \(\mathbf{e}_2 = [-1, 1, 0] / \sqrt{2}\)

  • Z-axis: \(\mathbf{e}_3 = [0, 0, 1]\)

The frame can be created as follows:

import numpy
from py3dframe import Frame

origin = numpy.array([-1, -2, -3])
x_axis = numpy.array([1, 1, 0]) / numpy.sqrt(2)
y_axis = numpy.array([-1, 1, 0]) / numpy.sqrt(2)
z_axis = numpy.array([0, 0, 1])

parent = ... # Define the parent frame if needed, otherwise parent=None to use the canonical frame.

frame = Frame.from_axes(origin=origin, x_axis=x_axis, y_axis=y_axis, z_axis=z_axis, parent=parent)

print("Origin of the frame:", frame.origin)
print("X-axis of the frame:", frame.x_axis)
print("Y-axis of the frame:", frame.y_axis)
print("Z-axis of the frame:", frame.z_axis)
# Output:
# Origin of the frame: [[-1.] [-2.] [-3.]]
# X-axis of the frame: [[ 0.70710678] [ 0.70710678] [ 0.        ]]
# Y-axis of the frame: [[-0.70710678] [ 0.70710678] [ 0.        ]]
# Z-axis of the frame: [[0.] [0.] [1.]]

If you like to work with a given convention, you can specify it with the convention parameter in order to access the translation and rotation in this convention.