dynamics_quaternions Module



Contents


Interfaces

public interface abs

  • private pure elemental function quat_abs(q) result(rst)

    Computes the magnitude of a quaternion.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: q

    The quaternion.

    Return Value real(kind=real64)

    The magnitude of the quaternion.

public interface aimag

  • private pure function quat_aimag(q) result(rst)

    Returns the imaginary component of the quaternion.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: q

    The quaternion.

    Return Value real(kind=real64), dimension(3)

    The imaginary component as a vector.

public interface assignment(=)

  • private pure elemental subroutine quat_assign(x, y)

    Assigns a quaternion to another.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(out) :: x

    The resulting quaternion.

    type(quaternion), intent(in) :: y

    The source quaternion.

  • private pure subroutine quat_assign_vec4(x, y)

    Assigns a 4-element vector to a quaternion.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(out) :: x

    The resulting quaternion.

    real(kind=real64), intent(in), dimension(4) :: y

    The source vector.

public interface conjg

  • private pure elemental function quat_conjg(q) result(rst)

    Computes the conjugate of a quaternion.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: q

    The quaternion.

    Return Value type(quaternion)

    The conjugate of the quaternion.

public interface dot_product

  • private pure elemental function quat_dot_prd(x, y) result(rst)

    Computes the dot product of two quaternions.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: x

    The left-hand-side argument.

    type(quaternion), intent(in) :: y

    The right-hand-side argument.

    Return Value real(kind=real64)

    The dot product.

public interface exp

  • private pure elemental function quat_exp(q) result(rst)

    Evaluates the exponential function for a quaternion.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: q

    The quaternion.

    Return Value type(quaternion)

    The resulting quaternion.

public interface log

  • private pure elemental function quat_log(q) result(rst)

    Evalautes the natural logarithm function for a quaternion.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: q

    The quaternion.

    Return Value type(quaternion)

    The resulting quaternion.

public interface operator(*)

  • private pure elemental function quat_scalar_mult(x, y) result(rst)

    Multiplies a quaternion with a scalar.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: x

    The quaternion.

    real(kind=real64), intent(in) :: y

    The scalar.

    Return Value type(quaternion)

    The resulting quaternion.

  • private pure elemental function scalar_quat_mult(x, y) result(rst)

    Multiplies a quaternion with a scalar.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: x

    The scalar.

    type(quaternion), intent(in) :: y

    The quaternion.

    Return Value type(quaternion)

    The resulting quaternion.

  • private pure elemental function quat_multiply(x, y) result(rst)

    Multiplies two quaternions.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: x

    The left-hand-side argument.

    type(quaternion), intent(in) :: y

    The right-hand-side argument.

    Return Value type(quaternion)

    The resulting quaternion.

  • private pure function quat_vec3_mult(x, y) result(rst)

    Multiplies a quaternion with a 3-element vector.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: x

    The quaternion.

    real(kind=real64), intent(in), dimension(3) :: y

    The vector.

    Return Value type(quaternion)

    The resulting quaternion.

public interface operator(**)

  • private pure elemental function quat_pwr(q, exponent) result(rst)

    Computes the result of a quaternion raised to an exponent.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: q

    The quaternion base.

    real(kind=real64), intent(in) :: exponent

    The exponent.

    Return Value type(quaternion)

    The resulting quaternion.

  • private pure elemental function quat_int_pwr(q, exponent) result(rst)

    Computes the result of a quaternion raised to an exponent.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: q

    The quaternion base.

    integer(kind=int32), intent(in) :: exponent

    The exponent.

    Return Value type(quaternion)

    The resulting quaternion.

public interface operator(+)

  • private pure elemental function quat_add(x, y) result(rst)

    Adds two quaternions together.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: x

    The left-hand-side argument.

    type(quaternion), intent(in) :: y

    The right-hand-side argument.

    Return Value type(quaternion)

    The resulting quaternion.

public interface operator(-)

  • private pure elemental function quat_subtract(x, y) result(rst)

    Subtracts two quaternions.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: x

    The left-hand-side argument.

    type(quaternion), intent(in) :: y

    The right-hand-side argument.

    Return Value type(quaternion)

    The resulting quaternion.

  • private pure elemental function quat_negate(x) result(rst)

    Negates a quaternion.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: x

    The quaternion.

    Return Value type(quaternion)

    The resulting quaternion.

public interface operator(/)

  • private pure elemental function quat_scalar_div(x, y) result(rst)

    Divides a quaternion by a scalar.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: x

    The quaternion.

    real(kind=real64), intent(in) :: y

    The scalar.

    Return Value type(quaternion)

    The resulting quaternion.

  • private pure elemental function quat_divide(x, y) result(rst)

    Divides a quaternion by another.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: x

    The left-hand-side argument.

    type(quaternion), intent(in) :: y

    The right-hand-side argument.

    Return Value type(quaternion)

    The resulting quaternion.

public interface quaternion

  • private pure function quat_init_array(x) result(rst)

    Constructs a quaternion from a 4-element array stored such that [w, x, y, z].

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in), dimension(4) :: x

    The array from which to initialize the quaternion stored in the order [w, x, y, z].

    Return Value type(quaternion)

    The resulting quaternion.

  • private pure function quat_init_angle_axis(angle, axis) result(rst)

    Constructs a quaternion given an axis and the angle of rotation about the axis.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: angle

    The rotation angle, in radians.

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

    A 3-element vector defining the axis about which the rotation occurrs.

    Return Value type(quaternion)

    The resulting quaternion.

  • private pure function quat_init_mtx(r) result(rst)

    Constructs a quaternion from a 3-by-3 rotation matrix using the Stanley method.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in), dimension(3, 3) :: r

    The rotation matrix.

    Return Value type(quaternion)

    The resulting quaternion.

public interface real

  • private pure elemental function quat_real(q) result(rst)

    Returns the real component of the quaternion.

    Arguments

    Type IntentOptional Attributes Name
    type(quaternion), intent(in) :: q

    The quaternion.

    Return Value real(kind=real64)

    The real component.


Derived Types

type, public ::  quaternion

Defines a quaternion of the form:

Components

Type Visibility Attributes Name Initial
real(kind=real64), public :: w

The real component of the quaternion.

real(kind=real64), public :: x

The first element in the imaginary component of the quaternion.

real(kind=real64), public :: y

The second element in the imaginary component of the quaternion.

real(kind=real64), public :: z

The third element in the imaginary component of the quaternion.

Constructor

private pure function quat_init_array (x)

Constructs a quaternion from a 4-element array stored such that [w, x, y, z].

private pure function quat_init_angle_axis (angle, axis)

Constructs a quaternion given an axis and the angle of rotation about the axis.

private pure function quat_init_mtx (r)

Constructs a quaternion from a 3-by-3 rotation matrix using the Stanley method.

Type-Bound Procedures

procedure , public :: normalize => quat_normalize Subroutine
procedure , public :: to_angle_axis => quat_to_angle_axis Subroutine
procedure , public :: to_array => quat_to_vec4 Function
procedure , public :: to_matrix => quat_to_matrix Function
procedure , public :: to_roll_pitch_yaw => quat_to_rpy Subroutine

Functions

public pure elemental function inverse(q) result(rst)

Computes the inverse of a quaternion.

Arguments

Type IntentOptional Attributes Name
type(quaternion), intent(in) :: q

The quaternion.

Return Value type(quaternion)

The inverse of the supplied quaternion.