Skip to content

EulerAngle Class

The EulerAngle class represents attitude using Euler angle sequences for intuitive spacecraft orientation specification.

EulerAngle

EulerAngle(order: str, phi: float, theta: float, psi: float, angle_format: AngleFormat)

Represents a rotation using Euler angles.

Euler angles describe rotations as a sequence of three rotations about specified axes. The rotation sequence is specified by the order parameter (e.g., "XYZ", "ZYX").

Parameters:

Name Type Description Default
order str

Rotation sequence (e.g., "XYZ", "ZYX", "ZXZ")

required
phi float

First rotation angle in radians or degrees

required
theta float

Second rotation angle in radians or degrees

required
psi float

Third rotation angle in radians or degrees

required
angle_format AngleFormat

Units of input angles (RADIANS or DEGREES)

required
Example
import brahe as bh

# Create Euler angle rotation (roll, pitch, yaw in ZYX order)
e = bh.EulerAngle("ZYX", 0.1, 0.2, 0.3, bh.AngleFormat.RADIANS)
print(f"Roll={e.phi}, Pitch={e.theta}, Yaw={e.psi}")

# Convert to quaternion
q = e.to_quaternion()

# Convert to rotation matrix
dcm = e.to_rotation_matrix()

Initialize instance.

__doc__ class-attribute

__doc__ = 'Represents a rotation using Euler angles.\n\nEuler angles describe rotations as a sequence of three rotations about\nspecified axes. The rotation sequence is specified by the order parameter\n(e.g., "XYZ", "ZYX").\n\nArgs:\n    order (str): Rotation sequence (e.g., "XYZ", "ZYX", "ZXZ")\n    phi (float): First rotation angle in radians or degrees\n    theta (float): Second rotation angle in radians or degrees\n    psi (float): Third rotation angle in radians or degrees\n    angle_format (AngleFormat): Units of input angles (RADIANS or DEGREES)\n\nExample:\n    ```python\n    import brahe as bh\n\n    # Create Euler angle rotation (roll, pitch, yaw in ZYX order)\n    e = bh.EulerAngle("ZYX", 0.1, 0.2, 0.3, bh.AngleFormat.RADIANS)\n    print(f"Roll={e.phi}, Pitch={e.theta}, Yaw={e.psi}")\n\n    # Convert to quaternion\n    q = e.to_quaternion()\n\n    # Convert to rotation matrix\n    dcm = e.to_rotation_matrix()\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'.

order property

order: str

Get the rotation sequence order.

Returns:

Name Type Description
str str

Rotation sequence (e.g., "XYZ", "ZYX")

Example
import brahe as bh

e = bh.EulerAngle("XYZ", 0.1, 0.2, 0.3, bh.AngleFormat.RADIANS)
print(f"Order: {e.order}")

phi property

phi: float

Get the first rotation angle (phi) in radians.

Returns:

Name Type Description
float float

First rotation angle in radians

Example
import brahe as bh

e = bh.EulerAngle("XYZ", 0.1, 0.2, 0.3, bh.AngleFormat.RADIANS)
print(f"Phi: {e.phi}")

psi property

psi: float

Get the third rotation angle (psi) in radians.

Returns:

Name Type Description
float float

Third rotation angle in radians

Example
import brahe as bh

e = bh.EulerAngle("XYZ", 0.1, 0.2, 0.3, bh.AngleFormat.RADIANS)
print(f"Psi: {e.psi}")

theta property

theta: float

Get the second rotation angle (theta) in radians.

Returns:

Name Type Description
float float

Second rotation angle in radians

Example
import brahe as bh

e = bh.EulerAngle("XYZ", 0.1, 0.2, 0.3, bh.AngleFormat.RADIANS)
print(f"Theta: {e.theta}")

__eq__ method descriptor

__eq__(value)

Return self==value.

__ge__ method descriptor

__ge__(value)

Return self>=value.

__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, order: str) -> EulerAngle

Create Euler angles from another Euler angle with different order.

Parameters:

Name Type Description Default
e EulerAngle

Source Euler angles

required
order str

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

required

Returns:

Name Type Description
EulerAngle EulerAngle

Equivalent Euler angles with new order

Example
import brahe as bh

e1 = bh.EulerAngle("XYZ", 0.1, 0.2, 0.3, bh.AngleFormat.RADIANS)
e2 = bh.EulerAngle.from_euler_angle(e1, "ZYX")

from_euler_axis builtin

from_euler_axis(e: EulerAxis, order: str) -> EulerAngle

Create Euler angles from an Euler axis representation.

Parameters:

Name Type Description Default
e EulerAxis

Euler axis representation

required
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 = bh.EulerAngle.from_euler_axis(ea, "XYZ")

from_quaternion builtin

from_quaternion(q: Quaternion, order: str) -> EulerAngle

Create Euler angles from a quaternion.

Parameters:

Name Type Description Default
q Quaternion

Source quaternion

required
order str

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

required

Returns:

Name Type Description
EulerAngle EulerAngle

Equivalent Euler angles

Example
import brahe as bh

q = bh.Quaternion(1.0, 0.0, 0.0, 0.0)
e = bh.EulerAngle.from_quaternion(q, "XYZ")

from_rotation_matrix builtin

from_rotation_matrix(r: RotationMatrix, order: str) -> EulerAngle

Create Euler angles from a rotation matrix.

Parameters:

Name Type Description Default
r RotationMatrix

Rotation matrix

required
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

r = bh.RotationMatrix.from_array(np.eye(3))
e = bh.EulerAngle.from_rotation_matrix(r, "XYZ")

from_vector builtin

from_vector(v: ndarray, order: str, angle_format: AngleFormat) -> EulerAngle

Create Euler angles from a numpy array.

Parameters:

Name Type Description Default
v ndarray

3-element array [phi, theta, psi]

required
order str

Rotation sequence (e.g., "XYZ", "ZYX")

required
angle_format AngleFormat

Units of input angles (RADIANS or DEGREES)

required

Returns:

Name Type Description
EulerAngle EulerAngle

New Euler angle instance

Example
import brahe as bh
import numpy as np

v = np.array([0.1, 0.2, 0.3])
euler = bh.EulerAngle.from_vector(v, "XYZ", bh.AngleFormat.RADIANS)

to_euler_angle method descriptor

to_euler_angle(order: str) -> EulerAngle

Convert to Euler angles with different rotation sequence.

Parameters:

Name Type Description Default
order str

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

required

Returns:

Name Type Description
EulerAngle EulerAngle

Equivalent Euler angles with new order

Example
import brahe as bh

e1 = bh.EulerAngle("XYZ", 0.1, 0.2, 0.3, bh.AngleFormat.RADIANS)
e2 = e1.to_euler_angle("ZYX")

to_euler_axis method descriptor

to_euler_axis() -> EulerAxis

Convert to Euler axis representation.

Returns:

Name Type Description
EulerAxis EulerAxis

Equivalent Euler axis

Example
import brahe as bh

e = bh.EulerAngle("XYZ", 0.1, 0.2, 0.3, bh.AngleFormat.RADIANS)
ea = e.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

e = bh.EulerAngle("XYZ", 0.1, 0.2, 0.3, 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

e = bh.EulerAngle("XYZ", 0.1, 0.2, 0.3, bh.AngleFormat.RADIANS)
r = e.to_rotation_matrix()