Rotation

giant.rotations:

class giant.rotations.Rotation(data=None)[source]

A class to represent and manipulate rotations in GIANT.

The Rotation class is the main way that attitude and rotation information is communicated in GIANT. It provides a number of convenient features that make handling attitude data and rotations much easier. The first of these features is is the ability to initialize the class with a rotation vector, rotation matrix, or rotation quaternion as described in the Rotation Representations table. For any case, simply provide the constructor with your current representation of your rotation and it will interpret the type of input (based on its shape) and store the appropriate data.

The next feature is property based aliases with caching and setting capabilities. These properties allow you to quickly get any of the 3 primary rotation representations(quaternion, matrix, vector), caching the result so the conversion doesn’t need to be performed every time you need the representation (but smartly knowing when the cache needs updated because the object has been updated). They also allow you to update the entire object in place by directly setting to any of them.

The final feature is operator overloading so that rotation transformations are easy. This means that you can do things like:

>>> from giant.rotations import Rotation
>>> from numpy import pi
>>> rotation_A2B = Rotation([pi, 0, 0])
>>> rotation_B2C = Rotation([0, pi/2, 0])
>>> rotation_A2C = rotation_B2C*rotation_A2B
>>> rotation_A2C
Rotation(array([ 7.07106781e-01,  4.32978028e-17, -7.07106781e-01,  4.32978028e-17]))

In addition to the multiplication operator, the equality operator is also overloaded to check that the quaternion representation of two objects is the same.

In general when a rotation needs to be expressed the Rotation object is used in GIANT.

Parameters:

data (Sequence | ndarray | Rotation | None) – The rotation data to initialize the class with

property quaternion: ndarray

This property stores the quaternion representation of the attitude as a numpy array.

It also enables setting the rotation represented for this object. When setting the rotation data for this object, the input should have a length of 4 and be convertable to a numpy array. It should also be of unit length (as is required for rotation quaternions). If the set value is not of unit length then it will be automatically normalized before being stored and a warning will be printed.

In order to make the quaternion representations unique in GIANT, setting a quaternion to this property will enforce that the scalar component is positive.

property q: ndarray

This is an alias to the quaternion property.

property matrix: ndarray

This property stores the matrix representation of the attitude as a numpy array.

It also enables setting the rotation represented for this object. When setting the rotation data for this object , the input should be an orthonormal matrix (Sequence of Sequences) of size 3x3. When setting this property, the quaternion property is automatically updated

property vector: ndarray

This property stores the vector representation of the attitude as a numpy array.

It also enables setting the rotation represented for this object. When setting the rotation data for this object, the input should be a length 3 rotation vector (Sequence) according to the form specified in the Rotation Representations. When setting this property, the quaternion property is automatically updated.

property q_vector: ndarray

This is an alias to the first three elements of the quaternion array (the vector portion of the quaternion)

This property is read only.

property q_scalar: float

This is an alias to the last element of the quaternion array (the scalar portion of the quaternion)

This property is read only.

Summary of Methods

inv

This method returns the inverse rotation of the current instance as a new Rotation object.

interp_attitude

This method interprets attitude data based on its shape and type.

rotate

Performs a left inplace rotation by other.

copy

Returns a deep copy of self.