Skip to content

EulerAxis Class

The EulerAxis class represents attitude using axis-angle representation (Euler's rotation theorem).

EulerAxis

EulerAxis(axis: ndarray, angle: float, angle_format: AngleFormat)

Represents a rotation using Euler axis-angle representation.

The Euler axis-angle representation describes a rotation as a single rotation about a specified axis by a given angle. This is also known as the axis-angle or rotation vector representation.

Parameters:

Name Type Description Default
axis ndarray

3-element unit vector specifying rotation axis

required
angle float

Rotation angle in radians or degrees

required
angle_format AngleFormat

Units of input angle (RADIANS or DEGREES)

required
Example
import brahe as bh
import numpy as np

# Rotation of 90 degrees about z-axis
axis = np.array([0.0, 0.0, 1.0])
e = bh.EulerAxis(axis, np.pi/2, bh.AngleFormat.RADIANS)
print(f"Angle: {e.angle} rad")

# Convert to quaternion
q = e.to_quaternion()

Initialize instance.

__doc__ class-attribute

__doc__ = 'Represents a rotation using Euler axis-angle representation.\n\nThe Euler axis-angle representation describes a rotation as a single rotation\nabout a specified axis by a given angle. This is also known as the axis-angle\nor rotation vector representation.\n\nArgs:\n    axis (numpy.ndarray): 3-element unit vector specifying rotation axis\n    angle (float): Rotation angle in radians or degrees\n    angle_format (AngleFormat): Units of input angle (RADIANS or DEGREES)\n\nExample:\n    ```python\n    import brahe as bh\n    import numpy as np\n\n    # Rotation of 90 degrees about z-axis\n    axis = np.array([0.0, 0.0, 1.0])\n    e = bh.EulerAxis(axis, np.pi/2, bh.AngleFormat.RADIANS)\n    print(f"Angle: {e.angle} rad")\n\n    # Convert to quaternion\n    q = e.to_quaternion()\n    ```'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

__module__ class-attribute

__module__ = 'brahe._brahe'

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to 'utf-8'. errors defaults to 'strict'.

angle property

angle: float

Get the rotation angle in radians.

Returns:

Name Type Description
float float

Rotation angle in radians

Example
import brahe as bh
import numpy as np

axis = np.array([0.0, 0.0, 1.0])
e = bh.EulerAxis(axis, 1.5708, bh.AngleFormat.RADIANS)
print(f"Angle: {e.angle}")

axis property

axis: ndarray

Get the rotation axis as a numpy array.

Returns:

Type Description
ndarray

numpy.ndarray: 3-element unit vector specifying rotation axis

Example
import brahe as bh
import numpy as np

axis = np.array([0.0, 0.0, 1.0])
e = bh.EulerAxis(axis, 1.5708, bh.AngleFormat.RADIANS)
print(f"Axis: {e.axis}")

__eq__ method descriptor

__eq__(value)

Return self==value.

__ge__ method descriptor

__ge__(value)

Return self>=value.

__getitem__ method descriptor

__getitem__(key: str) -> Any

Return self[key].

__gt__ method descriptor

__gt__(value)

Return self>value.

__le__ method descriptor

__le__(value)

Return self<=value.

__lt__ method descriptor

__lt__(value)

Return self<value.

__ne__ method descriptor

__ne__(value)

Return self!=value.

__new__ builtin

__new__(*args, **kwargs)

Create and return a new object. See help(type) for accurate signature.

__repr__ method descriptor

__repr__() -> str

Return repr(self).

__str__ method descriptor

__str__() -> str

Return str(self).

from_euler_angle builtin

from_euler_angle(e: EulerAngle) -> EulerAxis

Create an Euler axis from Euler angles.

Parameters:

Name Type Description Default
e EulerAngle

Euler angle representation

required

Returns:

Name Type Description
EulerAxis EulerAxis

Equivalent Euler axis

Example
import brahe as bh

euler = bh.EulerAngle("XYZ", 0.1, 0.2, 0.3, bh.AngleFormat.RADIANS)
e = bh.EulerAxis.from_euler_angle(euler)

from_euler_axis builtin

from_euler_axis(e: EulerAxis) -> EulerAxis

Create an Euler axis from another Euler axis (copy constructor).

Parameters:

Name Type Description Default
e EulerAxis

Source Euler axis

required

Returns:

Name Type Description
EulerAxis EulerAxis

New Euler axis instance

Example
import brahe as bh
import numpy as np

axis = np.array([0.0, 0.0, 1.0])
e1 = bh.EulerAxis(axis, 1.5708, bh.AngleFormat.RADIANS)
e2 = bh.EulerAxis.from_euler_axis(e1)

from_quaternion builtin

from_quaternion(q: Quaternion) -> EulerAxis

Create an Euler axis from a quaternion.

Parameters:

Name Type Description Default
q Quaternion

Source quaternion

required

Returns:

Name Type Description
EulerAxis EulerAxis

Equivalent Euler axis

Example
import brahe as bh

q = bh.Quaternion(1.0, 0.0, 0.0, 0.0)
e = bh.EulerAxis.from_quaternion(q)

from_rotation_matrix builtin

from_rotation_matrix(r: RotationMatrix) -> EulerAxis

Create an Euler axis from a rotation matrix.

Parameters:

Name Type Description Default
r RotationMatrix

Rotation matrix

required

Returns:

Name Type Description
EulerAxis EulerAxis

Equivalent Euler axis

Example
import brahe as bh
import numpy as np

r = bh.RotationMatrix.from_array(np.eye(3))
e = bh.EulerAxis.from_rotation_matrix(r)

from_values builtin

from_values(x: float, y: float, z: float, angle: float, angle_format: AngleFormat) -> EulerAxis

Create an Euler axis from individual axis components and angle.

Parameters:

Name Type Description Default
x float

X component of rotation axis

required
y float

Y component of rotation axis

required
z float

Z component of rotation axis

required
angle float

Rotation angle in radians or degrees

required
angle_format AngleFormat

Units of input angle (RADIANS or DEGREES)

required

Returns:

Name Type Description
EulerAxis EulerAxis

New Euler axis instance

Example
import brahe as bh

e = bh.EulerAxis.from_values(0.0, 0.0, 1.0, 1.5708, bh.AngleFormat.RADIANS)

from_vector builtin

from_vector(v: ndarray, angle_format: AngleFormat, vector_first: bool) -> EulerAxis

Create an Euler axis from a numpy array.

Parameters:

Name Type Description Default
v ndarray

4-element array containing axis and angle

required
angle_format AngleFormat

Units of angle (RADIANS or DEGREES)

required
vector_first bool

If True, array is [x, y, z, angle], else [angle, x, y, z]

required

Returns:

Name Type Description
EulerAxis EulerAxis

New Euler axis instance

Example
import brahe as bh
import numpy as np

v = np.array([0.0, 0.0, 1.0, 1.5708])
e = bh.EulerAxis.from_vector(v, bh.AngleFormat.RADIANS, True)

to_euler_angle method descriptor

to_euler_angle(order: str) -> EulerAngle

Convert to Euler angle representation.

Parameters:

Name Type Description Default
order str

Desired rotation sequence (e.g., "XYZ", "ZYX")

required

Returns:

Name Type Description
EulerAngle EulerAngle

Equivalent Euler angles

Example
import brahe as bh
import numpy as np

axis = np.array([0.0, 0.0, 1.0])
ea = bh.EulerAxis(axis, 1.5708, bh.AngleFormat.RADIANS)
e = ea.to_euler_angle("XYZ")

to_euler_axis method descriptor

to_euler_axis() -> EulerAxis

Convert to Euler axis representation (returns self).

Returns:

Name Type Description
EulerAxis EulerAxis

This Euler axis

Example
import brahe as bh
import numpy as np

axis = np.array([0.0, 0.0, 1.0])
e1 = bh.EulerAxis(axis, 1.5708, bh.AngleFormat.RADIANS)
e2 = e1.to_euler_axis()

to_quaternion method descriptor

to_quaternion() -> Quaternion

Convert to quaternion representation.

Returns:

Name Type Description
Quaternion Quaternion

Equivalent quaternion

Example
import brahe as bh
import numpy as np

axis = np.array([0.0, 0.0, 1.0])
e = bh.EulerAxis(axis, 1.5708, bh.AngleFormat.RADIANS)
q = e.to_quaternion()

to_rotation_matrix method descriptor

to_rotation_matrix() -> RotationMatrix

Convert to rotation matrix representation.

Returns:

Name Type Description
RotationMatrix RotationMatrix

Equivalent rotation matrix

Example
import brahe as bh
import numpy as np

axis = np.array([0.0, 0.0, 1.0])
e = bh.EulerAxis(axis, 1.5708, bh.AngleFormat.RADIANS)
r = e.to_rotation_matrix()

to_vector method descriptor

to_vector(angle_format: AngleFormat, vector_first: bool) -> ndarray

Convert Euler axis to a numpy array.

Parameters:

Name Type Description Default
angle_format AngleFormat

Units for output angle (RADIANS or DEGREES)

required
vector_first bool

If True, returns [x, y, z, angle], else [angle, x, y, z]

required

Returns:

Type Description
ndarray

numpy.ndarray: 4-element array containing axis and angle