rotlib_m Module

Euler angle ranges:

  • XYZ, ZYX: phi in [-pi, pi], theta in [-pi/2, pi/2], psi in [-pi, pi]
  • XZY, YZX: phi in [-pi, pi], theta in [-pi, pi], psi in [-pi/2, pi/2]
  • ZXY, YXZ: phi in [-pi/2, pi/2], theta in [-pi, pi], psi in [-pi, pi]

Euler angle sequence: XYZ (world). First rotation about X, second rotation about Y, and the third rotation about Z axis of the world(i.e. fixed) frame. This is the same as the sequence used in Blender.

In contrast, the XYZ sequence is understood in the Aerospace community as: XYZ: First rotation about Z-axis, second rotation about Y-axis, and the third rotation about X-axis of the body frame.

Reference: http://www.geometrictools.com/Documentation/EulerAngles.pdf



Functions

public function mat_is_rotmat(mat)

Returns .true. if a (3,3) matrix is a rotation matrix.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: mat

(3,3). Matrix to check.

Return Value logical

public function quat_is_normalized(q)

Returns .true. if quaternion is normalized, i.e. if it is a unit quaternion

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: q

A quaternion

Return Value logical

public function quat_angle_between(p, q) result(angle)

Returns the angle between two unit quaternions

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: p

Unit quaternion.

real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

Return Value real(kind=rp)

Angle in radian.

public function mat_is_dcm(mat)

Returns true if a (3,3) matrix is a direction cosine matrix.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: mat

Matrix to check.

Return Value logical


Subroutines

public subroutine align(v, old, new, valigned)

Rotates vectors such that a set of mutually orthogonal unit vectors aligns with another set of mutually orthogonal unit vectors.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(:,:) :: v

(3,n). Vectors to align.

real(kind=rp), intent(in), dimension(:,:) :: old

(3,m). A set of at most three mutually orthogonal unit vectors. m must be one of 1, 2 or 3.

real(kind=rp), intent(in), dimension(:,:) :: new

(3,m). Another set of mutually orthogonal unit vectors of the same shape as old. The angles between the vectors must be the same as those of old.

real(kind=rp), intent(out), dimension(:,:) :: valigned

(3,n). Aligned vectors, of the same shape as v.

public subroutine quat_rand(q)

Returns a random unit quaternion.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(out), dimension(4) :: q

Unit quaternion.

public subroutine quat_identity(q)

Returns the identity unit quaternion.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(out), dimension(4) :: q

Unit quaternion.

public subroutine quat_conjugated(q)

Conjugates a quaternion in-place.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(inout), dimension(4) :: q

On entry, a quaternion. On return, the conjugated quaternion.

public subroutine quat_inverted(q)

Inverts a quaternion in-place.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(inout), dimension(4) :: q

On entry, a quaternion. On return, the inverted quaternion.

public subroutine quat_normalized(q)

Normalizes a quaternion in-place.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(inout), dimension(4) :: q

On entry, a quaternion. On return, the normalized quaternion.

public subroutine quat_prod(p, q, pq, normalize)

Calculates the product of two quaternions

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: p

Quaternion.

real(kind=rp), intent(in), dimension(4) :: q

Quaternion.

real(kind=rp), intent(out), dimension(4) :: pq

Product of p and q. This is a unit quaternion if normalize is .true..

logical, intent(in), optional :: normalize

Whether to normalize the product, defaults to .true..

public subroutine quat_interpolate(q1, q2, t, q)

Interpolates between two unit quaternions.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: q1

Unit quaternion.

real(kind=rp), intent(in), dimension(4) :: q2

Unit quaternion.

real(kind=rp), intent(in) :: t

Interpolation factor, 0 <= t <= 1.

real(kind=rp), intent(out), dimension(4) :: q

Interpolated unit quaternion.

public subroutine quat_deriv_to_angvel_mat(qdot, mat)

Returns the matrix mapping the derivative of a unit quaternion to angular velocity.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: qdot

Derivative of a unit quaternion.

real(kind=rp), intent(out), dimension(3,4) :: mat

Angular velocity matrix.

public subroutine quat_deriv_to_angvel(q, qdot, angvel)

Calculates the angular velocity from a unit quaternion and its time derivative.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

real(kind=rp), intent(in), dimension(4) :: qdot

Derivative of q.

real(kind=rp), intent(out), dimension(3) :: angvel

Angular velocity.

public subroutine quat_deriv_from_angvel_mat(q, mat)

Returns the matrix mapping angular velocity to time derivative of a unit quaternion.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

real(kind=rp), intent(out), dimension(4,3) :: mat

Quaternion derivative matrix.

public subroutine quat_deriv_from_angvel(q, angvel, qdot)

Calculates the time derivative of a unit quaternion from angular velocity.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

real(kind=rp), intent(in), dimension(3) :: angvel

Angular velocity.

real(kind=rp), intent(out), dimension(4) :: qdot

Time derivative of q.

public subroutine quat_rotmat(q, rotmat)

Returns the rotation matrix corresponding to a unit quaternion.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

real(kind=rp), intent(out), dimension(3,3) :: rotmat

Rotation matrix.

public subroutine quat_shiftmat(q, forward, shiftmat)

Returns the shifter matrix corresponding to a unit quaternion.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

logical, intent(in) :: forward

Whether to shift forward, i.e., along the orientation or shift reverse.

real(kind=rp), intent(out), dimension(3,3) :: shiftmat

Shifter matrix.

public subroutine quat_rotate_vectors(v, q, vrot)

Rotates vectors by a unit quaternion.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(:,:) :: v

(3,n). Vectors to rotate.

real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

real(kind=rp), intent(out), dimension(:,:) :: vrot

(3,n) Rotated vectors.

public subroutine quat_shift_vectors(v, q, forward, vshift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by a unit quaternion, shifts vectors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(:,:) :: v

(3,n). Vectors to shift.

real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

logical, intent(in) :: forward

If .true., shift from A to B. If .false., shift from B to A.

real(kind=rp), intent(out), dimension(:,:) :: vshift

(3,n) Shifted vectors.

public subroutine quat_shift_tensor2(a, q, forward, ashift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by a unit quaternion, shifts second-order tensors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: a

A second-order tensor.

real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

logical, intent(in) :: forward

If .true., shift from A to B. If .false., shift from B to A.

real(kind=rp), intent(out), dimension(3,3) :: ashift

Shifted second-order tensor.

public subroutine quat_shift_tensor3(a, q, forward, ashift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by a unit quaternion, shifts third-order tensors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3,3) :: a

A third-order tensor.

real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

logical, intent(in) :: forward

If .true., shift from A to B. If .false., shift from B to A.

real(kind=rp), intent(out), dimension(3,3,3) :: ashift

Shifted third-order tensor.

public subroutine quat_to_aa(q, axis, angle)

Converts a unit quaternion to an axis-angle representation.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

real(kind=rp), intent(out), dimension(3) :: axis

Unit vector along the axis of rotation.

real(kind=rp), intent(out) :: angle

Angle in radian.

public subroutine quat_to_dcm(q, dcm)

Converts a unit quaternion to a direction cosine matrix.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

real(kind=rp), intent(out), dimension(3,3) :: dcm

Direction cosine matrix.

public subroutine quat_to_euler(q, seq, world, euler)

Converts a unit quaternion to an Euler angle sequence.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(4) :: q

Unit quaternion.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

real(kind=rp), intent(out), dimension(3) :: euler

Euler angles.

public subroutine aa_fix(axis, angle, normalize)

Modifies axis and angle to ensure a right handed rotation with angle .

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(inout), dimension(3) :: axis

Axis of rotation. If this is not a unit vector, set normalize to True.

real(kind=rp), intent(inout) :: angle

Angle in radian.

logical, intent(in), optional :: normalize

Whether to normalize the axis to a unit vector.

public subroutine aa_rand(axis, angle)

Generates a random orientation in axis-angle representation. The axis is a random vector drawn from a uniform distribution on the surface of a unit sphere. The current implementation in based on the algorithm from Allen & Tildesley p. 349.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(out), dimension(3) :: axis
real(kind=rp), intent(out) :: angle

public subroutine aa_rotmat(axis, angle, rotmat)

Returns the rotation matrix corresponding to an axis-angle representation.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3) :: axis

Unit vector along the axis.

real(kind=rp), intent(in) :: angle

Angle of rotation in radian. 0 <= angle < pi.

real(kind=rp), intent(out), dimension(3,3) :: rotmat

Rotation matrix.

public subroutine aa_from_rotmat(rotmat, axis, angle)

Extracts axis and angle from a rotation matrix.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: rotmat

Rotation matrix (must be orthonormal).

real(kind=rp), intent(out), dimension(3) :: axis

Unit vector along the axis.

real(kind=rp), intent(out) :: angle

Angle of rotation in radian.

public subroutine aa_rotate_vectors(v, axis, angle, vrot)

Rotates vectors about axis by angle.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(:,:) :: v

(3,n). Vectors to rotate.

real(kind=rp), intent(in), dimension(3) :: axis

Unit vector along the axis.

real(kind=rp), intent(in) :: angle

Angle of rotation in radian. 0 <= angle < pi.

real(kind=rp), intent(out), dimension(:,:) :: vrot

(3,n). Rotated vectors.

public subroutine aa_shiftmat(axis, angle, forward, shiftmat)

Returns the shifter matrix corresponding to an axis-angle representation.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3) :: axis

Unit vector along the axis.

real(kind=rp), intent(in) :: angle

Angle of rotation in radian. 0 <= angle < pi.

logical, intent(in) :: forward

Whether to shift forward, i.e., along the orientation or shift reverse.

real(kind=rp), intent(out), dimension(3,3) :: shiftmat

Shifter matrix.

public subroutine aa_shift_vectors(v, axis, angle, forward, vshift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by an axis-angle representation, shifts vectors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(:,:) :: v

(3,n). Vectors to shift.

real(kind=rp), intent(in), dimension(3) :: axis

Unit vector along the axis.

real(kind=rp), intent(in) :: angle

Angle of rotation in radian. 0 <= angle < pi.

logical, intent(in) :: forward

If True, shift from A to B. If False, shift from B to A.

real(kind=rp), intent(out), dimension(:,:) :: vshift

(3,n). Shifted vectors.

public subroutine aa_shift_tensor2(a, axis, angle, forward, ashift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by an axis-angle representation, shifts second-order tensors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: a

Second-order tensor

real(kind=rp), intent(in), dimension(3) :: axis

Unit vector along the axis.

real(kind=rp), intent(in) :: angle

Angle of rotation in radian. 0 <= angle < pi.

logical, intent(in) :: forward

If True, shift from A to B. If False, shift from B to A.

real(kind=rp), intent(out), dimension(3,3) :: ashift

Shifted second-order tensor.

public subroutine aa_shift_tensor3(a, axis, angle, forward, ashift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by an axis-angle representation, shifts third-order tensors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3,3) :: a

Third-order tensor

real(kind=rp), intent(in), dimension(3) :: axis

Unit vector along the axis.

real(kind=rp), intent(in) :: angle

Angle of rotation in radian. 0 <= angle < pi.

logical, intent(in), optional :: forward

If True, shift from A to B. If False, shift from B to A.

real(kind=rp), intent(out), dimension(3,3,3) :: ashift

Shifted third-order tensor.

public subroutine aa_to_quat(axis, angle, q)

Converts an axis-angle representation to a unit quaternion.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3) :: axis

Unit vector along the axis.

real(kind=rp), intent(in) :: angle

Angle of rotation in radian. 0 <= angle < pi.

real(kind=rp), intent(out), dimension(4) :: q

Unit quaternion.

public subroutine aa_to_dcm(axis, angle, dcm)

Converts an axis-angle representation to a direction cosine matrix.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3) :: axis

Unit vector along the axis.

real(kind=rp), intent(in) :: angle

Angle of rotation in radian. 0 <= angle < pi.

real(kind=rp), intent(out), dimension(3,3) :: dcm

Direction cosine matrix.

public subroutine aa_to_euler(axis, angle, seq, world, euler)

Coverts an axis-angle representation to Euler angles.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3) :: axis

Unit vector along the axis.

real(kind=rp), intent(in) :: angle

Angle in radian. 0 <= angle < pi.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

real(kind=rp), intent(out), dimension(3) :: euler

Euler angles.

public subroutine dcm_from_axes(A, B, dcm)

Returns the direction cosine matrix of axes(i.e. frame) B with respect to axes(i.e. frame) A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: A

The columns of A represent the orthonormal basis vectors of frame A.

real(kind=rp), intent(in), dimension(3,3) :: B

The columns of B represent the orthonormal basis vectors of frame B.

real(kind=rp), intent(out), dimension(3,3) :: dcm

Direction cosine matrix of frame B with respect to frame A

public subroutine dcm_rotmat(dcm, rotmat)

Returns the rotation matrix corresponding to a direction cosine matrix.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: dcm

Direction cosine matrix.

real(kind=rp), intent(out), dimension(3,3) :: rotmat

Rotation matrix.

public subroutine dcm_shiftmat(dcm, forward, shiftmat)

Returns the shifter matrix corresponding to a direction cosine matrix.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: dcm

Direction cosine matrix.

logical, intent(in) :: forward

Whether to shift forward, i.e., along the orientation or shift reverse.

real(kind=rp), intent(out), dimension(3,3) :: shiftmat

Shifter matrix.

public subroutine dcm_rotate_vectors(v, dcm, vrot)

Rotates vectors by a direction cosine matrix.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(:,:) :: v

(3,n). Vectors to rotate.

real(kind=rp), intent(in), dimension(3,3) :: dcm

Direction cosine matrix.

real(kind=rp), intent(out), dimension(:,:) :: vrot

(3,n). Rotated vectors.

public subroutine dcm_shift_vectors(v, dcm, forward, vshift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by a direction cosine matrix, shifts vectors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(:,:) :: v

(3,n). Vectors to shift.

real(kind=rp), intent(in), dimension(3,3) :: dcm

Direction cosine matrix.

logical, intent(in) :: forward

If True, shift from A to B. If False, shift from B to A.

real(kind=rp), intent(out), dimension(:,:) :: vshift

(3,n). Shifted vectors.

public subroutine dcm_shift_tensor2(a, dcm, forward, ashift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by a direction cosine matrix, shifts second-order tesnors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: a

A second-order tensor.

real(kind=rp), intent(in), dimension(3,3) :: dcm

Direction cosine matrix.

logical, intent(in) :: forward

If True, shift from A to B. If False, shift from B to A.

real(kind=rp), intent(out), dimension(3,3) :: ashift

(3,n). Shifted second-order tensor.

public subroutine dcm_shift_tensor3(a, dcm, forward, ashift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by a direction cosine matrix, shifts third-order tesnors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3,3) :: a

A second-order tensor.

real(kind=rp), intent(in), dimension(3,3) :: dcm

Direction cosine matrix.

logical, intent(in) :: forward

If True, shift from A to B. If False, shift from B to A.

real(kind=rp), intent(out), dimension(3,3,3) :: ashift

(3,n). Shifted second-order tensor.

public subroutine dcm_to_quat(dcm, q)

Converts a direction cosine matrix to a unit quaternion.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: dcm

Direction cosine matrix.

real(kind=rp), intent(out), dimension(4) :: q

Unit quaternion.

public subroutine dcm_to_aa(dcm, axis, angle)

Converts a direction cosine matrix to an axis-angle representation.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: dcm

Direction cosine matrix.

real(kind=rp), intent(out), dimension(3) :: axis

Unit vector along the axis.

real(kind=rp), intent(out) :: angle

Angle in radian.

public subroutine dcm_to_euler(dcm, seq, world, euler)

Converts a direction cosine matrix to Euler angles.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: dcm

Direction cosine matrix.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

real(kind=rp), intent(out), dimension(3) :: euler

Euler angles

public subroutine euler_rotmat(euler, seq, world, rotmat)

Returns the rotation matrix for a set of Euler angles.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3) :: euler
character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

real(kind=rp), intent(out), dimension(3,3) :: rotmat

Rotation matrix.

public subroutine euler_shiftmat(euler, seq, world, forward, shiftmat)

Returns the shifter matrix for a set of Euler angles.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3) :: euler

Euler angles.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

logical, intent(in) :: forward

Whether to shift forward, i.e., along the orientation or shift reverse.

real(kind=rp), intent(out), dimension(3,3) :: shiftmat

Shifter matrix.

public subroutine euler_rotate_vectors(v, euler, seq, world, vrot)

Rotates vectors with a set of Euler angles.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(:,:) :: v

(3,n). Vectors to rotate.

real(kind=rp), intent(in), dimension(3) :: euler

Euler angles.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

real(kind=rp), intent(out), dimension(:,:) :: vrot

(3,n). Rotated vectors.

public subroutine euler_shift_vectors(v, euler, seq, world, forward, vshift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by three Euler angles, shifts vectors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(:,:) :: v

(3,n). Vectors to rotate.

real(kind=rp), intent(in), dimension(3) :: euler

Euler angles.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

logical, intent(in) :: forward

If .true., shift from A to B. If .false., shift from B to A.

real(kind=rp), intent(out), dimension(:,:) :: vshift

(3,n). Shifted vectors.

public subroutine euler_shift_tensor2(a, euler, seq, world, forward, ashift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by three Euler angles, shifts second-order tensors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3) :: a

Second-order tensor.

real(kind=rp), intent(in), dimension(3) :: euler

Euler angles.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

logical, intent(in) :: forward

If .true., shift from A to B. If .false., shift from B to A.

real(kind=rp), intent(out), dimension(3,3) :: ashift

Shifted second-order tensor.

public subroutine euler_shift_tensor3(a, euler, seq, world, forward, ashift)

Given two frames A and B such that the orientation of frame B with respect to frame A is given by three Euler angles, shifts third-order tensors from A to B or B to A.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3,3,3) :: a

Third-order tensor.

real(kind=rp), intent(in), dimension(3) :: euler

Euler angles.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

logical, intent(in) :: forward

If .true., shift from A to B. If .false., shift from B to A.

real(kind=rp), intent(out), dimension(3,3,3) :: ashift

Shifted third-order tensor.

public subroutine euler_to_quat(euler, seq, world, q)

Convert Euler angles to a unit quaternion.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3) :: euler

Euler angles.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

real(kind=rp), intent(out), dimension(4) :: q

Unit quaternion.

public subroutine euler_to_aa(euler, seq, world, axis, angle)

Convert Euler angles to an axis-angle representation.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3) :: euler

Euler angles.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

real(kind=rp), intent(out), dimension(3) :: axis

Unit vector along the axis of rotation.

real(kind=rp), intent(out) :: angle

Angle of rotation in radian.

public subroutine euler_to_dcm(euler, seq, world, dcm)

Convert Euler angles to a direction cosine matrix.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3) :: euler

Euler angles.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Euler angle sequence.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

real(kind=rp), intent(out), dimension(3,3) :: dcm

Direction cosine matrix.

public subroutine euler_to_euler(euler, seq, world, to_seq, to_world, to_euler)

Convert one set of Euler angles to another.

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in), dimension(3) :: euler

Euler angles.

character(len=3), intent(in) :: seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Sequence for euler.

logical, intent(in) :: world

Whether the Euler angles are with respect to the world frame or not.

character(len=3), intent(out) :: to_seq

'XYZ'|'XZY' | 'YXZ' | 'YZX' | 'ZXY' | 'ZYX'. Convert euler with sequence seq to the sequence to_seq.

logical, intent(out) :: to_world

Whether the converted euler angles are with respect to the world frame or not.

real(kind=rp), intent(out), dimension(3) :: to_euler

Converted Euler angles.