From 7a5c8c114b55a35228a9a72dadc048c459d5a8e5 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Wed, 22 May 2024 16:22:07 +0000 Subject: [PATCH] build based on 6461852 --- dev/.documenter-siteinfo.json | 2 +- dev/index.html | 2 +- dev/lib/library/index.html | 94 +++++++++++++------------- dev/man/composing_rotations/index.html | 2 +- dev/man/conversions/index.html | 2 +- dev/man/dcm/index.html | 2 +- dev/man/euler_angle_axis/index.html | 2 +- dev/man/euler_angles/index.html | 2 +- dev/man/inv_rotations/index.html | 2 +- dev/man/kinematics/index.html | 2 +- dev/man/quaternions/index.html | 2 +- dev/man/random/index.html | 18 ++--- 12 files changed, 66 insertions(+), 66 deletions(-) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 17293b5..eeeb649 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.3","generation_timestamp":"2024-05-22T16:20:20","documenter_version":"1.4.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.3","generation_timestamp":"2024-05-22T16:22:03","documenter_version":"1.4.1"}} \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 313b59b..d317229 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,3 +1,3 @@ Home · Reference Frame Rotations

ReferenceFrameRotations.jl

This module contains functions related to 3D rotations of reference frames. It is used on a daily basis on projects at the Brazilian National Institute for Space Research (INPE).

Installation

This package can be installed using:

julia> Pkg.update()
-julia> Pkg.add("ReferenceFrameRotations")

Status

This packages supports the following representations of 3D rotations:

  • Euler Angle and Axis;
  • Euler Angles;
  • Direction Cosine Matrices (DCMs);
  • Quaternions.

However, composing rotations is only currently supported for DCMs and Quaternions.

Roadmap

This package will be continuously enhanced. Next steps will be to add other representations of 3D rotations such as Rodrigues parameters, etc.

Manual outline

Library documentation

+julia> Pkg.add("ReferenceFrameRotations")

Status

This packages supports the following representations of 3D rotations:

However, composing rotations is only currently supported for DCMs and Quaternions.

Roadmap

This package will be continuously enhanced. Next steps will be to add other representations of 3D rotations such as Rodrigues parameters, etc.

Manual outline

Library documentation

diff --git a/dev/lib/library/index.html b/dev/lib/library/index.html index 215875b..693b54e 100644 --- a/dev/lib/library/index.html +++ b/dev/lib/library/index.html @@ -1,5 +1,5 @@ -Library · Reference Frame Rotations

Library

Documentation for ReferenceFrameRotations.jl.

ReferenceFrameRotations.DCMType
DCM{T}

Direction Cosine Matrix (DCM) of type T, which is a 3x3 static matrix of type T.

Examples

julia> DCM(1.0I)
+Library · Reference Frame Rotations

Library

Documentation for ReferenceFrameRotations.jl.

ReferenceFrameRotations.DCMType
DCM{T}

Direction Cosine Matrix (DCM) of type T, which is a 3x3 static matrix of type T.

Examples

julia> DCM(1.0I)
 DCM{Float64}:
  1.0  0.0  0.0
  0.0  1.0  0.0
@@ -9,16 +9,16 @@
 DCM{Int64}:
  1   0   0
  0  -1   0
- 0   0  -1
source
ReferenceFrameRotations.EulerAngleAxisType
EulerAngleAxis{T}

The definition of Euler Angle and Axis to represent a 3D rotation.

Fields

  • a::T: The Euler angle [rad].
  • v::SVector{3, T}: The unitary vector aligned with the Euler axis.

Constructor

EulerAngleAxis(a::T1, v::AbstractVector{T2}) where {T1,T2}

Create an Euler Angle and Axis representation structure with angle a [rad] and vector v.

The vector v will not be normalized.

The returned structure type will be selected according to the input types.

Examples

julia> EulerAngleAxis(pi / 3, [sqrt(2), sqrt(2), 0])
+ 0   0  -1
source
ReferenceFrameRotations.EulerAngleAxisType
EulerAngleAxis{T}

The definition of Euler Angle and Axis to represent a 3D rotation.

Fields

  • a::T: The Euler angle [rad].
  • v::SVector{3, T}: The unitary vector aligned with the Euler axis.

Constructor

EulerAngleAxis(a::T1, v::AbstractVector{T2}) where {T1,T2}

Create an Euler Angle and Axis representation structure with angle a [rad] and vector v.

The vector v will not be normalized.

The returned structure type will be selected according to the input types.

Examples

julia> EulerAngleAxis(pi / 3, [sqrt(2), sqrt(2), 0])
 EulerAngleAxis{Float64}:
   Euler angle:   1.0472 rad ( 60.0000 deg)
-   Euler axis: [  1.4142,   1.4142,   0.0000]
source
ReferenceFrameRotations.EulerAnglesType
EulerAngles{T}

The definition of Euler Angles, which is composed of three angles a1, a2, and a3 together with a rotation sequence rot_seq.

Fields

  • a1::T: First rotation [rad].
  • a2::T: Second rotation [rad].
  • a3::T: Third rotation [rad].
  • rot_seq::Symbol: Rotation sequence.
Info

rot_seq is provided by a symbol with three characters, each one indicating the rotation axis of the corresponding angle, e.g. :ZYX. The valid values for rot_seq are:

  • :XYX, :XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and ZYZ.

Constructor

EulerAngles(a1::T1, a2::T2, a3::T3, rot_seq::Symbol = :ZYX) where {T1, T2, T3}

Create a new instance of EulerAngles with the angles a1, a2, and a3 and the rotation sequence rot_seq.

The type will be inferred from T1, T2, and T3.

If rot_seq is not provided, then it defaults to :ZYX.

Examples

julia> EulerAngles(pi / 2, pi / 4, -pi, :XYZ)
+   Euler axis: [  1.4142,   1.4142,   0.0000]
source
ReferenceFrameRotations.EulerAnglesType
EulerAngles{T}

The definition of Euler Angles, which is composed of three angles a1, a2, and a3 together with a rotation sequence rot_seq.

Fields

  • a1::T: First rotation [rad].
  • a2::T: Second rotation [rad].
  • a3::T: Third rotation [rad].
  • rot_seq::Symbol: Rotation sequence.
Info

rot_seq is provided by a symbol with three characters, each one indicating the rotation axis of the corresponding angle, e.g. :ZYX. The valid values for rot_seq are:

  • :XYX, :XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and ZYZ.

Constructor

EulerAngles(a1::T1, a2::T2, a3::T3, rot_seq::Symbol = :ZYX) where {T1, T2, T3}

Create a new instance of EulerAngles with the angles a1, a2, and a3 and the rotation sequence rot_seq.

The type will be inferred from T1, T2, and T3.

If rot_seq is not provided, then it defaults to :ZYX.

Examples

julia> EulerAngles(pi / 2, pi / 4, -pi, :XYZ)
 EulerAngles{Float64}:
   R(X) :  1.5707963267948966 rad  ( 90.0°)
   R(Y) :  0.7853981633974483 rad  ( 45.0°)
-  R(Z) : -3.141592653589793  rad  (-180.0°)
source
ReferenceFrameRotations.QuaternionType
Quaternion{T}

The definition of the quaternion.

Fields

  • q0::T: Quaternion real part.
  • q1::T: X component of the quaternion imaginary part.
  • q2::T: Y component of the quaternion imaginary part.
  • q3::T: Z component of the quaternion imaginary part.
Note

The quaternion q in this structure is represented by:

q = q0 + q1.i + q2.j + q3.k

Example

julia> Quaternion(cosd(45), sind(45), 0, 0)
+  R(Z) : -3.141592653589793  rad  (-180.0°)
source
ReferenceFrameRotations.QuaternionType
Quaternion{T}

The definition of the quaternion.

Fields

  • q0::T: Quaternion real part.
  • q1::T: X component of the quaternion imaginary part.
  • q2::T: Y component of the quaternion imaginary part.
  • q3::T: Z component of the quaternion imaginary part.
Note

The quaternion q in this structure is represented by:

q = q0 + q1.i + q2.j + q3.k

Example

julia> Quaternion(cosd(45), sind(45), 0, 0)
 Quaternion{Float64}:
-  + 0.7071067811865476 + 0.7071067811865476.i + 0.0.j + 0.0.k
source
ReferenceFrameRotations.QuaternionMethod
Quaternion(q0::T0, q1::T1, q2::T2, q3::T3) where {T0, T1, T2, T3}

Create the following quaternion:

q0 + q1.i + q2.j + q3.k

in which:

  • q0 is the real part of the quaternion.
  • q1 is the X component of the quaternion vectorial part.
  • q2 is the Y component of the quaternion vectorial part.
  • q3 is the Z component of the quaternion vectorial part.
Note

The quaternion type is obtained by promoting T0, T1, T2, and T3.

Examples

julia> Quaternion(1, 0, 0, 0)
+  + 0.7071067811865476 + 0.7071067811865476.i + 0.0.j + 0.0.k
source
ReferenceFrameRotations.QuaternionMethod
Quaternion(q0::T0, q1::T1, q2::T2, q3::T3) where {T0, T1, T2, T3}

Create the following quaternion:

q0 + q1.i + q2.j + q3.k

in which:

  • q0 is the real part of the quaternion.
  • q1 is the X component of the quaternion vectorial part.
  • q2 is the Y component of the quaternion vectorial part.
  • q3 is the Z component of the quaternion vectorial part.
Note

The quaternion type is obtained by promoting T0, T1, T2, and T3.

Examples

julia> Quaternion(1, 0, 0, 0)
 Quaternion{Int64}:
   + 1 + 0⋅i + 0⋅j + 0⋅k
 
@@ -48,7 +48,7 @@
 
 julia> Quaternion(I, q)
 Quaternion{Float32}:
-  + 1.0 + 0.0⋅i + 0.0⋅j + 0.0⋅k
source
Base.:*Method
*(v::AbstractVector, q::Quaternion)
+  + 1.0 + 0.0⋅i + 0.0⋅j + 0.0⋅k
source
Base.:*Method
*(v::AbstractVector, q::Quaternion)
 *(q::Quaternion, v::AbstractVector)

Compute the multiplication qv * q or q * qv in which qv is a quaternion with real part 0 and vectorial/imaginary part v (Hamilton product).

Examples

julia> q = Quaternion(1, 0, 0, 0)
 Quaternion{Int64}:
   + 1 + 0⋅i + 0⋅j + 0⋅k
@@ -61,7 +61,7 @@
 
 julia> q * v
 Quaternion{Float64}:
-  + 0.0 + 0.0⋅i + 0.5⋅j + 0.866025⋅k
source
Base.:*Method
*(Θ₂::EulerAngles, Θ₁::EulerAngles)

Compute the composed rotation of Θ₁ -> Θ₂.

The rotation will be represented by Euler angles (see EulerAngles) with the same rotation sequence as Θ₂.

Examples

julia> ea1 = EulerAngles(deg2rad(35), 0, 0, :XYZ)
+  + 0.0 + 0.0⋅i + 0.5⋅j + 0.866025⋅k
source
Base.:*Method
*(Θ₂::EulerAngles, Θ₁::EulerAngles)

Compute the composed rotation of Θ₁ -> Θ₂.

The rotation will be represented by Euler angles (see EulerAngles) with the same rotation sequence as Θ₂.

Examples

julia> ea1 = EulerAngles(deg2rad(35), 0, 0, :XYZ)
 EulerAngles{Float64}:
   R(X) :  0.610865 rad  ( 35.0°)
   R(Y) :  0.0      rad  ( 0.0°)
@@ -77,14 +77,14 @@
 EulerAngles{Float64}:
   R(Z) :  0.0    rad  ( 0.0°)
   R(Y) : -0.0    rad  (-0.0°)
-  R(X) :  1.0472 rad  ( 60.0°)
source
Base.:*Method
*(λ::Number, q::Quaternion)
+  R(X) :  1.0472 rad  ( 60.0°)
source
Base.:*Method
*(λ::Number, q::Quaternion)
 *(q::Quaternion, λ::Number)

Compute λ * q or q * λ, in which λ is a scalar.

Examples

julia> q = Quaternion(1, 0, 0, 0)
 Quaternion{Int64}:
   + 1 + 0⋅i + 0⋅j + 0⋅k
 
 julia> 2 * q
 Quaternion{Int64}:
-  + 2 + 0⋅i + 0⋅j + 0⋅k
source
Base.:*Method
*(q1::Quaternion, q2::Quaternion)

Compute the quaternion multiplication q1 * q2 (Hamilton product).

If one of the operands is a UniformScaling:

*(u::UniformScaling, q::Quaternion)
+  + 2 + 0⋅i + 0⋅j + 0⋅k
source
Base.:*Method
*(q1::Quaternion, q2::Quaternion)

Compute the quaternion multiplication q1 * q2 (Hamilton product).

If one of the operands is a UniformScaling:

*(u::UniformScaling, q::Quaternion)
 *(q::Quaternion, u::UniformScaling)

then it is considered as the quaternion u.λ + 0 ⋅ i + 0 ⋅ j + 0 ⋅ k.

Examples

julia> q1 = Quaternion(cosd(30), 0, sind(30), 0)
 Quaternion{Float64}:
   + 0.866025 + 0.0⋅i + 0.5⋅j + 0.0⋅k
@@ -99,7 +99,7 @@
 
 julia> I * q1
 Quaternion{Float64}:
-  + 0.866025 + 0.0⋅i + 0.5⋅j + 0.0⋅k
source
Base.:*Method
*(av₂::EulerAngleAxis{T1}, av₁::EulerAngleAxis{T2}) where {T1,T2}

Compute the composed rotation of av₁ -> av₂.

The rotation will be represented by a Euler angle and axis (see EulerAngleAxis). By convention, the output angle will always be in the range [0, π] rad.

Notice that the vector representing the axis in av₁ and av₂ must be unitary. This function neither verifies this nor normalizes the vector.

Examples

julia> av1 = EulerAngleAxis(deg2rad(45), [sqrt(2)/2, sqrt(2)/2, 0])
+  + 0.866025 + 0.0⋅i + 0.5⋅j + 0.0⋅k
source
Base.:*Method
*(av₂::EulerAngleAxis{T1}, av₁::EulerAngleAxis{T2}) where {T1,T2}

Compute the composed rotation of av₁ -> av₂.

The rotation will be represented by a Euler angle and axis (see EulerAngleAxis). By convention, the output angle will always be in the range [0, π] rad.

Notice that the vector representing the axis in av₁ and av₂ must be unitary. This function neither verifies this nor normalizes the vector.

Examples

julia> av1 = EulerAngleAxis(deg2rad(45), [sqrt(2)/2, sqrt(2)/2, 0])
 EulerAngleAxis{Float64}:
   Euler angle : 0.785398 rad  (45.0°)
   Euler axis  : [0.707107, 0.707107, 0.0]
@@ -112,7 +112,7 @@
 julia> av1 * av2
 EulerAngleAxis{Float64}:
   Euler angle : 1.1781 rad  (67.5°)
-  Euler axis  : [0.707107, 0.707107, 0.0]
source
Base.:+Method
+(qa::Quaternion, qb::Quaternion)

Compute qa + qb.

If one of the operands is a UniformScaling:

+(u::UniformScaling, q::Quaternion)
+  Euler axis  : [0.707107, 0.707107, 0.0]
source
Base.:+Method
+(qa::Quaternion, qb::Quaternion)

Compute qa + qb.

If one of the operands is a UniformScaling:

+(u::UniformScaling, q::Quaternion)
 +(q::Quaternion, u::UniformScaling)

then it is considered as the quaternion u.λ + 0 ⋅ i + 0 ⋅ j + 0 ⋅ k.

Examples

julia> q1 = Quaternion(1, 0, 0, 0)
 Quaternion{Int64}:
   + 1 + 0⋅i + 0⋅j + 0⋅k
@@ -127,7 +127,7 @@
 
 julia> q1 + I
 Quaternion{Int64}:
-  + 2 + 0⋅i + 0⋅j + 0⋅k
source
Base.:-Method
-(qa::Quaternion, qb::Quaternion)

Compute qa - qb.

If one of the operands is a UniformScaling:

-(u::UniformScaling, q::Quaternion)
+  + 2 + 0⋅i + 0⋅j + 0⋅k
source
Base.:-Method
-(qa::Quaternion, qb::Quaternion)

Compute qa - qb.

If one of the operands is a UniformScaling:

-(u::UniformScaling, q::Quaternion)
 -(q::Quaternion, u::UniformScaling)

then it is considered as the quaternion u.λ + 0 ⋅ i + 0 ⋅ j + 0 ⋅ k.

Examples

julia> q1 = Quaternion(1, 0, 0, 0)
 Quaternion{Int64}:
   + 1 + 0⋅i + 0⋅j + 0⋅k
@@ -142,20 +142,20 @@
 
 julia> q1 - I
 Quaternion{Int64}:
-  + 0 + 0⋅i + 0⋅j + 0⋅k
source
Base.:-Method
-(q::Quaternion)

Return the quaterion -q.

Examples

julia> q = Quaternion(1, 0, 0, 0)
+  + 0 + 0⋅i + 0⋅j + 0⋅k
source
Base.:-Method
-(q::Quaternion)

Return the quaterion -q.

Examples

julia> q = Quaternion(1, 0, 0, 0)
 Quaternion{Int64}:
   + 1 + 0⋅i + 0⋅j + 0⋅k
 
 julia> -q
 Quaternion{Int64}:
-  - 1 + 0⋅i + 0⋅j + 0⋅k
source
Base.:/Method
/(λ::Number, q::Quaternion)
+  - 1 + 0⋅i + 0⋅j + 0⋅k
source
Base.:/Method
/(λ::Number, q::Quaternion)
 /(q::Quaternion, λ::Number)

Compute the division λ / q or q / λ, in which λ is a scalar.

Examples

julia> q = Quaternion(2, 0, 0, 0)
 Quaternion{Int64}:
   + 2 + 0⋅i + 0⋅j + 0⋅k
 
 julia> q / 2
 Quaternion{Float64}:
-  + 1.0 + 0.0⋅i + 0.0⋅j + 0.0⋅k
source
Base.:/Method
/(q1::Quaternion, q2::Quaternion)

Compute q1 * inv(q2) (Hamilton product).

If one of the operands is a UniformScaling:

/(u::UniformScaling, q::Quaternion)
+  + 1.0 + 0.0⋅i + 0.0⋅j + 0.0⋅k
source
Base.:/Method
/(q1::Quaternion, q2::Quaternion)

Compute q1 * inv(q2) (Hamilton product).

If one of the operands is a UniformScaling:

/(u::UniformScaling, q::Quaternion)
 /(q::Quaternion, u::UniformScaling)

then it is considered as the quaternion u.λ + 0 ⋅ i + 0 ⋅ j + 0 ⋅ k.

Examples

julia> q1 = Quaternion(cosd(75), 0, sind(75), 0)
 Quaternion{Float64}:
   + 0.258819 + 0.0⋅i + 0.965926⋅j + 0.0⋅k
@@ -170,7 +170,7 @@
 
 julia> q1 / (2 * I)
 Quaternion{Float64}:
-  + 0.12941 + 0.0⋅i + 0.482963⋅j + 0.0⋅k
source
Base.:\Method
\(v::AbstractVector, q::Quaternion)
+  + 0.12941 + 0.0⋅i + 0.482963⋅j + 0.0⋅k
source
Base.:\Method
\(v::AbstractVector, q::Quaternion)
 \(q::Quaternion, v::AbstractVector)

Compute the division qv \ q or q \ qv in which qv is a quaternion with real part 0 and vectorial/imaginary part v (Hamilton product).

Examples

julia> q = Quaternion(1, 0, 0, 0)
 Quaternion{Int64}:
   + 1 + 0⋅i + 0⋅j + 0⋅k
@@ -183,7 +183,7 @@
 
 julia> v \ q
 Quaternion{Float64}:
-  + 0.0 + 0.0⋅i - 0.5⋅j - 0.866025⋅k
source
Base.:\Method
\(q1::Quaternion, q2::Quaternion)

Compute inv(q1) * q2.

If one of the operands is a UniformScaling:

\(u::UniformScaling, q::Quaternion)
+  + 0.0 + 0.0⋅i - 0.5⋅j - 0.866025⋅k
source
Base.:\Method
\(q1::Quaternion, q2::Quaternion)

Compute inv(q1) * q2.

If one of the operands is a UniformScaling:

\(u::UniformScaling, q::Quaternion)
 \(q::Quaternion, u::UniformScaling)

then it is considered as the quaternion u.λ + 0 ⋅ i + 0 ⋅ j + 0 ⋅ k.

Examples

julia> q1 = Quaternion(cosd(75), 0, sind(75), 0)
 Quaternion{Float64}:
   + 0.258819 + 0.0⋅i + 0.965926⋅j + 0.0⋅k
@@ -194,13 +194,13 @@
 
 julia> q2 \ q1
 Quaternion{Float64}:
-  + 0.707107 + 0.0⋅i + 0.707107⋅j + 0.0⋅k
source
Base.conjMethod
conj(q::Quaternion)

Compute the complex conjugate of the quaternion q:

q0 - q1.i - q2.j - q3.k

See also: inv

Examples

julia> q = Quaternion(1, cosd(75), 0, sind(75))
+  + 0.707107 + 0.0⋅i + 0.707107⋅j + 0.0⋅k
source
Base.conjMethod
conj(q::Quaternion)

Compute the complex conjugate of the quaternion q:

q0 - q1.i - q2.j - q3.k

See also: inv

Examples

julia> q = Quaternion(1, cosd(75), 0, sind(75))
 Quaternion{Float64}:
   + 1.0 + 0.258819⋅i + 0.0⋅j + 0.965926⋅k
 
 julia> conj(q)
 Quaternion{Float64}:
-  + 1.0 - 0.258819⋅i - 0.0⋅j - 0.965926⋅k
source
Base.copyMethod
copy(q::Quaternion{T}) where T

Create a copy of the quaternion q.

source
Base.imagMethod
imag(q::Quaternion)

Return the vectorial or imaginary part of the quaternion q represented by a 3 × 1 vector of type SVector{3}.

See also: real, vect

Examples

julia> q = Quaternion(cosd(75), 0, sind(75), 0)
+  + 1.0 - 0.258819⋅i - 0.0⋅j - 0.965926⋅k
source
Base.copyMethod
copy(q::Quaternion{T}) where T

Create a copy of the quaternion q.

source
Base.imagMethod
imag(q::Quaternion)

Return the vectorial or imaginary part of the quaternion q represented by a 3 × 1 vector of type SVector{3}.

See also: real, vect

Examples

julia> q = Quaternion(cosd(75), 0, sind(75), 0)
 Quaternion{Float64}:
   + 0.258819 + 0.0⋅i + 0.965926⋅j + 0.0⋅k
 
@@ -208,7 +208,7 @@
 3-element StaticArraysCore.SVector{3, Float64} with indices SOneTo(3):
  0.0
  0.9659258262890683
- 0.0
source
Base.invMethod
inv(Θ::EulerAngles)

Return the Euler angles that represent the inverse rotation of Θ.

The rotation sequence of the result will be the inverse of the input. Hence, if the input rotation sequence is, for example, :XYZ, then the result will be represented using :ZYX.

Examples

julia> ea = EulerAngles(π / 3, π / 6,  2 / 3 * π, :ZYX)
+ 0.0
source
Base.invMethod
inv(Θ::EulerAngles)

Return the Euler angles that represent the inverse rotation of Θ.

The rotation sequence of the result will be the inverse of the input. Hence, if the input rotation sequence is, for example, :XYZ, then the result will be represented using :ZYX.

Examples

julia> ea = EulerAngles(π / 3, π / 6,  2 / 3 * π, :ZYX)
 EulerAngles{Float64}:
   R(Z) :  1.0472   rad  ( 60.0°)
   R(Y) :  0.523599 rad  ( 30.0°)
@@ -218,7 +218,7 @@
 EulerAngles{Float64}:
   R(X) : -2.0944   rad  (-120.0°)
   R(Y) : -0.523599 rad  (-30.0°)
-  R(Z) : -1.0472   rad  (-60.0°)
source
Base.invMethod
inv(q::Quaternion)

Compute the inverse of the quaternion q:

conj(q)
+  R(Z) : -1.0472   rad  (-60.0°)
source
Base.invMethod
inv(q::Quaternion)

Compute the inverse of the quaternion q:

conj(q)
 -------
   |q|²

See also: conj

Examples

julia> q = Quaternion(1, 0, cosd(75), sind(75))
 Quaternion{Float64}:
@@ -226,7 +226,7 @@
 
 julia> inv(q)
 Quaternion{Float64}:
-  + 0.5 - 0.0⋅i - 0.12941⋅j - 0.482963⋅k
source
Base.invMethod
inv(av::EulerAngleAxis)

Compute the inverse rotation of the Euler angle and axis av.

The Euler angle returned by this function will always be in the interval [0, π] rad.

Examples

julia> av = EulerAngleAxis(deg2rad(20), [sqrt(2) / 2, 0, sqrt(2) / 2])
+  + 0.5 - 0.0⋅i - 0.12941⋅j - 0.482963⋅k
source
Base.invMethod
inv(av::EulerAngleAxis)

Compute the inverse rotation of the Euler angle and axis av.

The Euler angle returned by this function will always be in the interval [0, π] rad.

Examples

julia> av = EulerAngleAxis(deg2rad(20), [sqrt(2) / 2, 0, sqrt(2) / 2])
 EulerAngleAxis{Float64}:
   Euler angle : 0.349066 rad  (20.0°)
   Euler axis  : [0.707107, 0.0, 0.707107]
@@ -244,17 +244,17 @@
 julia> inv(av)
 EulerAngleAxis{Float64}:
   Euler angle : 0.349066 rad  (20.0°)
-  Euler axis  : [0.707107, 0.0, 0.707107]
source
Base.realMethod
real(q::Quaternion)

Return the real part of the quaternion q: q0.

See also: imag, vect

Examples

julia> q = Quaternion(cosd(75), 0, sind(75), 0)
+  Euler axis  : [0.707107, 0.0, 0.707107]
source
Base.realMethod
real(q::Quaternion)

Return the real part of the quaternion q: q0.

See also: imag, vect

Examples

julia> q = Quaternion(cosd(75), 0, sind(75), 0)
 Quaternion{Float64}:
   + 0.258819 + 0.0⋅i + 0.965926⋅j + 0.0⋅k
 
 julia> real(q)
-0.25881904510252074
source
LinearAlgebra.normMethod
norm(q::Quaternion)

Compute the Euclidean norm of the quaternion q:

√(q0² + q1² + q2² + q3²)

Examples

julia> q = Quaternion(cosd(75), 0, sind(75), 0)
+0.25881904510252074
source
LinearAlgebra.normMethod
norm(q::Quaternion)

Compute the Euclidean norm of the quaternion q:

√(q0² + q1² + q2² + q3²)

Examples

julia> q = Quaternion(cosd(75), 0, sind(75), 0)
 Quaternion{Float64}:
   + 0.258819 + 0.0⋅i + 0.965926⋅j + 0.0⋅k
 
 julia> norm(q)
-1.0
source
ReferenceFrameRotations.angle_to_angleMethod
angle_to_angle(θ₁::Number, θ₂::Number, θ₃::Number, rot_seq_orig::Symbol, rot_seq_dest::Symbol)
 angle_to_angle(Θ::EulerAngles, rot_seq_dest::Symbol)

Convert the Euler angles θ₁, θ₂, and θ₃ [rad] with the rotation sequence rot_seq_orig to a new set of Euler angles with rotation sequence rot_seq_dest.

The input values of the origin Euler angles can also be passed inside the structure Θ (see EulerAngles).

The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ.

Example

julia> angle_to_angle(-pi / 2, -pi / 3, -pi / 4, :ZYX, :XYZ)
 EulerAngles{Float64}:
   R(X) : -1.0472   rad  (-60.0°)
@@ -277,7 +277,7 @@
 EulerAngles{Float64}:
   R(Z) : -2.70239 rad  (-154.836°)
   R(Y) :  1.46676 rad  ( 84.0393°)
-  R(Z) : -1.05415 rad  (-60.3984°)
source
ReferenceFrameRotations.angle_to_angleaxisFunction
angle_to_angleaxis(θ₁::Number, θ₂::Number, θ₃::Number, rot_seq::Symbol = :ZYX)
 angle_to_angleaxis(Θ::EulerAngles)

Convert the Euler angles θ₁, θ₂, and θ₃ [rad] with the rotation sequence rot_seq to an Euler angle and axis representation.

Those values can also be passed inside the structure Θ (see EulerAngles).

The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ. If no value is specified, then it defaults to :ZYX.

Example

julia> angle_to_angleaxis(1, 0, 0, :XYZ)
 EulerAngleAxis{Float64}:
   Euler angle : 1.0 rad  (57.2958°)
@@ -288,7 +288,7 @@
 julia> angle_to_angleaxis(Θ)
 EulerAngleAxis{Float64}:
   Euler angle : 1.93909 rad  (111.102°)
-  Euler axis  : [0.692363, 0.203145, 0.692363]
source
ReferenceFrameRotations.angle_to_dcmMethod
angle_to_dcm(θ₁::Number[, θ₂::Number[, θ₃::Number]], rot_seq::Symbol = :ZYX)
 angle_to_dcm(Θ::EulerAngles)

Create a direction cosine matrix that perform a set of rotations (θ₁, θ₂, θ₃) about the coordinate axes specified in rot_seq.

The input values of the origin Euler angles can also be passed inside the structure Θ (see EulerAngles).

The rotation sequence is defined by a Symbol specifing the rotation axes. The possible values depends on the number of rotations as follows:

  • 1 rotation (θ₁): :X, :Y, or :Z.
  • 2 rotations (θ₁, θ₂): :XY, :XZ, :YX, :YZ, :ZX, or :ZY.
  • 3 rotations (θ₁, θ₂, θ₃): :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, or :ZYZ

Remarks

This function assigns dcm = A3 * A2 * A1 in which Ai is the DCM related with the i-th rotation, i Є [1,2,3]. If the i-th rotation is not specified, then Ai = I.

Example

julia> angle_to_dcm(pi / 2, :X)
 DCM{Float64}:
  1.0   0.0          0.0
@@ -311,7 +311,7 @@
 DCM{Float64}:
   3.06162e-17  0.5       -0.866025
  -0.707107     0.612372   0.353553
-  0.707107     0.612372   0.353553
source
ReferenceFrameRotations.angle_to_quatMethod
angle_to_quat(θ₁::T1[, θ₂::T2[, θ₃::T3]], rot_seq::Symbol = :ZYX) where {T1<:Number, T2<:Number, T3<:Number}
 angle_to_quat(eulerang::EulerAngles)

Create a quaternion that perform a set of rotations (θ₁, θ₂, θ₃) about the coordinate axes specified in rot_seq.

The input values of the origin Euler angles can also be passed inside the structure Θ (see EulerAngles).

The rotation sequence is defined by a Symbol specifing the rotation axes. The possible values depends on the number of rotations as follows:

  • 1 rotation (θ₁): :X, :Y, or :Z.
  • 2 rotations (θ₁, θ₂): :XY, :XZ, :YX, :YZ, :ZX, or :ZY.
  • 3 rotations (θ₁, θ₂, θ₃): :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, or :ZYZ
Note

The type of the new quaternion will be obtained by promiting T1, T2, and T3.

Remarks

This function assigns q = q1 * q2 * q3 in which qi is the quaternion related with the i-th rotation, i Є [1,2,3]. If the i-th rotation is not specified, then qi = Quaternion(I).

Example

julia> angle_to_quat(pi / 2, :X)
 Quaternion{Float64}:
   + 0.707107 + 0.707107⋅i + 0.0⋅j + 0.0⋅k
@@ -326,7 +326,7 @@
 
 julia> angle_to_quat(pi / 2, pi / 3, pi / 4, :ZYX)
 Quaternion{Float64}:
-  + 0.701057 - 0.092296⋅i + 0.560986⋅j + 0.430459⋅k
source
ReferenceFrameRotations.angle_to_rotMethod
angle_to_rot([T,] θ₁::Number[, θ₂::Number[, θ₃::Number]], rot_seq::Symbol)
 angle_to_rot([T,] Θ::EulerAngles)

Create a rotation description of type T that perform a set of rotations (θ₁, θ₂, θ₃) about the coordinate axes specified in rot_seq.

The input values of the origin Euler angles can also be passed inside the structure Θ (see EulerAngles).

The rotation sequence is defined by a Symbol specifing the rotation axes. The possible values depends on the number of rotations as follows:

  • 1 rotation (θ₁): :X, :Y, or :Z.
  • 2 rotations (θ₁, θ₂): :XY, :XZ, :YX, :YZ, :ZX, or :ZY.
  • 3 rotations (θ₁, θ₂, θ₃): :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, or :ZYZ

Example

julia> dcm = angle_to_rot(pi / 5, :Z)
 3×3 StaticArrays.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
   0.809017  0.587785  0.0
@@ -355,14 +355,14 @@
 
 julia> q = angle_to_rot(Quaternion, pi / 2, pi / 3, pi / 4, :ZYX)
 Quaternion{Float64}:
-  + 0.701057 - 0.092296⋅i + 0.560986⋅j + 0.430459⋅k
source
ReferenceFrameRotations.angleaxis_to_angleMethod
angleaxis_to_angle(θ::Number, v::AbstractVector, rot_seq::Symbol)
 angleaxis_to_angle(av::EulerAngleAxis, rot_seq::Symbol)

Convert the Euler angle θ [rad] and Euler axis v to Euler angles with rotation sequence rot_seq.

Those values can also be passed inside the structure av (see EulerAngleAxis).

The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ. If no value is specified, then it defaults to :ZYX.

Warning

It is expected that the vector v is unitary. However, no verification is performed inside the function. The user must handle this situation.

Example

julia> av = EulerAngleAxis(deg2rad(45), [1, 0, 0]);
 
 julia> angleaxis_to_angle(av, :ZXY)
 EulerAngles{Float64}:
   R(Z) :  0.0      rad  ( 0.0°)
   R(X) :  0.785398 rad  ( 45.0°)
-  R(Y) :  0.0      rad  ( 0.0°)
source
ReferenceFrameRotations.angleaxis_to_dcmMethod
angleaxis_to_dcm(a::Number, v::AbstractVector)
 angleaxis_to_dcm(av::EulerAngleAxis)

Convert the Euler angle a [rad] and Euler axis v to a DCM.

Those values can also be passed inside the structure ea (see EulerAngleAxis).

Warning

It is expected that the vector v is unitary. However, no verification is performed inside the function. The user must handle this situation.

Example

julia> v = [1, 1, 1];
 
 julia> v /= norm(v);
@@ -379,14 +379,14 @@
 DCM{Float64}:
   0.333333   0.910684  -0.244017
  -0.244017   0.333333   0.910684
-  0.910684  -0.244017   0.333333
source
ReferenceFrameRotations.angleaxis_to_quatMethod
angleaxis_to_quat(θ::Number, v::AbstractVector)
 angleaxis_to_quat(angleaxis::EulerAngleAxis)

Convert the Euler angle θ [rad] and Euler axis v to a quaternion.

Those values can also be passed inside the structure ea (see EulerAngleAxis).

Warning

It is expected that the vector v is unitary. However, no verification is performed inside the function. The user must handle this situation.

Example

julia> v = [1, 1, 1];
 
 julia> v /= norm(v);
 
 julia> angleaxis_to_quat(pi / 2, v)
 Quaternion{Float64}:
-  + 0.707107 + 0.408248⋅i + 0.408248⋅j + 0.408248⋅k
source
ReferenceFrameRotations.compose_rotationMethod
compose_rotation(R1, [, R2, R3, R4, R5, ...])

Compute a composed rotation using the rotations R1, R2, R3, R4, ..., in the following order:

 First rotation
+  + 0.707107 + 0.408248⋅i + 0.408248⋅j + 0.408248⋅k
source
ReferenceFrameRotations.compose_rotationMethod
compose_rotation(R1, [, R2, R3, R4, R5, ...])

Compute a composed rotation using the rotations R1, R2, R3, R4, ..., in the following order:

 First rotation
  |
  |
 R1 => R2 => R3 => R4 => ...
@@ -427,7 +427,7 @@
 
 julia> compose_rotation(q1, q2)
 Quaternion{Float64}:
-  + 1.0 + 0.0⋅i + 2.08167e-17⋅j + 5.55112e-17⋅k
source
ReferenceFrameRotations.dcm_to_angleMethod
dcm_to_angle(dcm::DCM, rot_seq::Symbol=:ZYX)

Convert the dcm to Euler Angles (see EulerAngles) given a rotation sequence rot_seq.

The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ. If no value is specified, then it defaults to :ZYX.

Gimbal-lock and special cases

If the rotations are about three different axes, e.g. :XYZ, :ZYX, etc., then a second rotation of ±90˚ yields a gimbal-lock. This means that the rotations between the first and third axes have the same effect. In this case, the net rotation angle is assigned to the first rotation, and the angle of the third rotation is set to 0.

If the rotations are about two different axes, e.g. :XYX, :YXY, etc., then a rotation about the duplicated axis yields multiple representations. In this case, the entire angle is assigned to the first rotation and the third rotation is set to 0.

Example

julia> D = DCM([1. 0. 0.; 0. 0. -1; 0. -1 0.]);
+  + 1.0 + 0.0⋅i + 2.08167e-17⋅j + 5.55112e-17⋅k
source
ReferenceFrameRotations.dcm_to_angleMethod
dcm_to_angle(dcm::DCM, rot_seq::Symbol=:ZYX)

Convert the dcm to Euler Angles (see EulerAngles) given a rotation sequence rot_seq.

The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ. If no value is specified, then it defaults to :ZYX.

Gimbal-lock and special cases

If the rotations are about three different axes, e.g. :XYZ, :ZYX, etc., then a second rotation of ±90˚ yields a gimbal-lock. This means that the rotations between the first and third axes have the same effect. In this case, the net rotation angle is assigned to the first rotation, and the angle of the third rotation is set to 0.

If the rotations are about two different axes, e.g. :XYX, :YXY, etc., then a rotation about the duplicated axis yields multiple representations. In this case, the entire angle is assigned to the first rotation and the third rotation is set to 0.

Example

julia> D = DCM([1. 0. 0.; 0. 0. -1; 0. -1 0.]);
 
 julia> dcm_to_angle(D,:XYZ)
 EulerAngles{Float64}:
@@ -449,21 +449,21 @@
 EulerAngles{Float64}:
   R(X) :  3.0 rad  ( 171.887°)
   R(Y) :  0.0 rad  ( 0.0°)
-  R(X) :  0.0 rad  ( 0.0°)
source
ReferenceFrameRotations.dcm_to_angleaxisMethod
dcm_to_angleaxis(dcm::DCM{T}) where T<:Number

Convert the dcm to an Euler angle and axis representation.

By convention, the returned Euler angle will always be in the interval [0, π].

source
ReferenceFrameRotations.dcm_to_quatMethod
dcm_to_quat(dcm::DCM)

Convert the dcm to a quaternion.

The type of the quaternion will be automatically selected by the constructor Quaternion to avoid InexactError.

Remarks

By convention, the real part of the quaternion will always be positive. Moreover, the function does not check if dcm is a valid direction cosine matrix. This must be handle by the user.

This algorithm was obtained from [1].

Example

julia> dcm = angle_to_dcm(pi / 2, 0.0, 0.0, :XYZ);
+  R(X) :  0.0 rad  ( 0.0°)
source
ReferenceFrameRotations.dcm_to_angleaxisMethod
dcm_to_angleaxis(dcm::DCM{T}) where T<:Number

Convert the dcm to an Euler angle and axis representation.

By convention, the returned Euler angle will always be in the interval [0, π].

source
ReferenceFrameRotations.dcm_to_quatMethod
dcm_to_quat(dcm::DCM)

Convert the dcm to a quaternion.

The type of the quaternion will be automatically selected by the constructor Quaternion to avoid InexactError.

Remarks

By convention, the real part of the quaternion will always be positive. Moreover, the function does not check if dcm is a valid direction cosine matrix. This must be handle by the user.

This algorithm was obtained from [1].

Example

julia> dcm = angle_to_dcm(pi / 2, 0.0, 0.0, :XYZ);
 
 julia> q = dcm_to_quat(dcm)
 Quaternion{Float64}:
-  + 0.707107 + 0.707107⋅i + 0.0⋅j + 0.0⋅k

References

  • [1]: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/
source
ReferenceFrameRotations.ddcmMethod
ddcm(Dba::DCM, wba_b::AbstractArray)

Compute the time-derivative of the dcm that rotates a reference frame a into alignment with the reference frame b in which the angular velocity of b with respect to a, and represented in b, is wba_b.

Example

julia> D = DCM(1.0I);
+  + 0.707107 + 0.707107⋅i + 0.0⋅j + 0.0⋅k

References

  • [1]: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/
source
ReferenceFrameRotations.ddcmMethod
ddcm(Dba::DCM, wba_b::AbstractArray)

Compute the time-derivative of the dcm that rotates a reference frame a into alignment with the reference frame b in which the angular velocity of b with respect to a, and represented in b, is wba_b.

Example

julia> D = DCM(1.0I);
 
 julia> ddcm(D, [1, 0, 0])
 3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
  0.0   0.0  0.0
  0.0   0.0  1.0
- 0.0  -1.0  0.0
source
ReferenceFrameRotations.dquatMethod
dquat(qba::Quaternion, wba_b::AbstractVector)

Compute the time-derivative of the quaternion qba that rotates a reference frame a into alignment to the reference frame b in which the angular velocity of b with respect to a, and represented in b, is wba_b.

Examples

julia> q = Quaternion(1.0I);
+ 0.0  -1.0  0.0
source
ReferenceFrameRotations.dquatMethod
dquat(qba::Quaternion, wba_b::AbstractVector)

Compute the time-derivative of the quaternion qba that rotates a reference frame a into alignment to the reference frame b in which the angular velocity of b with respect to a, and represented in b, is wba_b.

Examples

julia> q = Quaternion(1.0I);
 
 julia> dquat(q,[1;0;0])
 Quaternion{Float64}:
-  - 0.0 + 0.5⋅i + 0.0⋅j + 0.0⋅k
source
ReferenceFrameRotations.inv_rotationMethod
inv_rotation(R)

Compute the inverse rotation of R, which can be:

  • A direction cosine matrix (DCM);
  • An Euler angle and axis (EulerAngleAxis);
  • A set of Euler anlges (EulerAngles); or
  • A quaternion (Quaternion).

The output will have the same type as R.

Note

If R is a DCM, than its transpose is computed instead of its inverse to reduce the computational burden. The both are equal if the DCM has unit norm. This must be verified by the user.

Note

If R is a quaternion, than its conjugate is computed instead of its inverse to reduce the computational burden. The both are equal if the quaternion has unit norm. This must be verified by the used.

Example

julia> D = angle_to_dcm(pi / 3, pi / 4, pi / 5, :ZYX);
+  - 0.0 + 0.5⋅i + 0.0⋅j + 0.0⋅k
source
ReferenceFrameRotations.inv_rotationMethod
inv_rotation(R)

Compute the inverse rotation of R, which can be:

  • A direction cosine matrix (DCM);
  • An Euler angle and axis (EulerAngleAxis);
  • A set of Euler anlges (EulerAngles); or
  • A quaternion (Quaternion).

The output will have the same type as R.

Note

If R is a DCM, than its transpose is computed instead of its inverse to reduce the computational burden. The both are equal if the DCM has unit norm. This must be verified by the user.

Note

If R is a quaternion, than its conjugate is computed instead of its inverse to reduce the computational burden. The both are equal if the quaternion has unit norm. This must be verified by the used.

Example

julia> D = angle_to_dcm(pi / 3, pi / 4, pi / 5, :ZYX);
 
 julia> inv_rotation(D)
 DCM{Float64}:
@@ -490,30 +490,30 @@
 
 julia> inv_rotation(q)
 Quaternion{Float64}:
-  + 0.820071 - 0.0652687⋅i - 0.45794⋅j - 0.336918⋅k
source
ReferenceFrameRotations.orthonormalizeMethod
orthonormalize(dcm::DCM)

Perform the Gram-Schmidt orthonormalization process in the dcm and return the new matrix.

Warning

This function does not check if the columns of the input matrix span a three-dimensional space. If not, then the returned matrix should have NaN. Notice, however, that such input matrix is not a valid direction cosine matrix.

Example

julia> D = DCM(3I)
+  + 0.820071 - 0.0652687⋅i - 0.45794⋅j - 0.336918⋅k
source
ReferenceFrameRotations.orthonormalizeMethod
orthonormalize(dcm::DCM)

Perform the Gram-Schmidt orthonormalization process in the dcm and return the new matrix.

Warning

This function does not check if the columns of the input matrix span a three-dimensional space. If not, then the returned matrix should have NaN. Notice, however, that such input matrix is not a valid direction cosine matrix.

Example

julia> D = DCM(3I)
 
 julia> orthonormalize(D)
 3×3 StaticArrays.SArray{Tuple{3,3},Float64,2,9}:
  1.0  0.0  0.0
  0.0  1.0  0.0
- 0.0  0.0  1.0
source
ReferenceFrameRotations.quat_to_angleFunction
quat_to_angle(q::Quaternion, rot_seq::Symbol = :ZYX)

Convert the quaternion q to Euler Angles (see EulerAngles) given a rotation sequence rot_seq.

The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ. If no value is specified, then it defaults to :ZYX.

Examples

julia> q = Quaternion(cosd(45/2), sind(45/2), 0, 0);
+ 0.0  0.0  1.0
source
ReferenceFrameRotations.quat_to_angleFunction
quat_to_angle(q::Quaternion, rot_seq::Symbol = :ZYX)

Convert the quaternion q to Euler Angles (see EulerAngles) given a rotation sequence rot_seq.

The rotation sequence is defined by a :Symbol. The possible values are: :XYX, XYZ, :XZX, :XZY, :YXY, :YXZ, :YZX, :YZY, :ZXY, :ZXZ, :ZYX, and :ZYZ. If no value is specified, then it defaults to :ZYX.

Examples

julia> q = Quaternion(cosd(45/2), sind(45/2), 0, 0);
 
 julia> quat_to_angle(q, :XYZ)
 EulerAngles{Float64}:
   R(X) :  0.785398 rad  ( 45.0°)
   R(Y) :  0.0      rad  ( 0.0°)
-  R(Z) :  0.0      rad  ( 0.0°)
source
ReferenceFrameRotations.quat_to_angleaxisMethod
quat_to_angleaxis(q::Quaternion{T}) where T

Convert the quaternion q to a Euler angle and axis representation (see EulerAngleAxis). By convention, the Euler angle will be kept between [0, π] rad.

Remarks

This function will not fail if the quaternion norm is not 1. However, the meaning of the results will not be defined, because the input quaternion does not represent a 3D rotation. The user must handle such situations.

Examples

julia> q = Quaternion(cosd(45/2), sind(45/2), 0, 0);
+  R(Z) :  0.0      rad  ( 0.0°)
source
ReferenceFrameRotations.quat_to_angleaxisMethod
quat_to_angleaxis(q::Quaternion{T}) where T

Convert the quaternion q to a Euler angle and axis representation (see EulerAngleAxis). By convention, the Euler angle will be kept between [0, π] rad.

Remarks

This function will not fail if the quaternion norm is not 1. However, the meaning of the results will not be defined, because the input quaternion does not represent a 3D rotation. The user must handle such situations.

Examples

julia> q = Quaternion(cosd(45/2), sind(45/2), 0, 0);
 
 julia> quat_to_angleaxis(q)
 EulerAngleAxis{Float64}:
   Euler angle : 0.785398 rad  (45.0°)
-  Euler axis  : [1.0, 0.0, 0.0]
source
ReferenceFrameRotations.quat_to_dcmMethod
quat_to_dcm(q::Quaternion)

Convert the quaternion q to a Direction Cosine Matrix (DCM).

Examples

julia> q = Quaternion(cosd(45/2), sind(45/2), 0, 0);
+  Euler axis  : [1.0, 0.0, 0.0]
source
ReferenceFrameRotations.quat_to_dcmMethod
quat_to_dcm(q::Quaternion)

Convert the quaternion q to a Direction Cosine Matrix (DCM).

Examples

julia> q = Quaternion(cosd(45/2), sind(45/2), 0, 0);
 
 julia> quat_to_dcm(q)
 DCM{Float64}:
  1.0   0.0       0.0
  0.0   0.707107  0.707107
- 0.0  -0.707107  0.707107
source
ReferenceFrameRotations.smallangle_to_dcmMethod
smallangle_to_dcm(θx::Number, θy::Number, θz::Number; normalize = true)

Create a direction cosine matrix from three small rotations of angles θx, θy, and θz [rad] about the axes X, Y, and Z, respectively.

If the keyword normalize is true, then the matrix will be normalized using the function orthonormalize.

Example

julia> smallangle_to_dcm(+0.01, -0.01, +0.01)
+ 0.0  -0.707107  0.707107
source
ReferenceFrameRotations.smallangle_to_dcmMethod
smallangle_to_dcm(θx::Number, θy::Number, θz::Number; normalize = true)

Create a direction cosine matrix from three small rotations of angles θx, θy, and θz [rad] about the axes X, Y, and Z, respectively.

If the keyword normalize is true, then the matrix will be normalized using the function orthonormalize.

Example

julia> smallangle_to_dcm(+0.01, -0.01, +0.01)
 DCM{Float64}:
   0.9999     0.00989903  0.010098
  -0.009999   0.999901    0.00989802
@@ -523,9 +523,9 @@
 DCM{Float64}:
   1.0    0.01  0.01
  -0.01   1.0   0.01
- -0.01  -0.01  1.0
source
ReferenceFrameRotations.smallangle_to_quatMethod
smallangle_to_quat(θx::Number, θy::Number, θz::Number)

Create a quaternion from three small rotations of angles θx, θy, and θz [rad] about the axes X, Y, and Z, respectively.

Note

The quaternion is always normalized.

Example

julia> smallangle_to_quat(+0.01, -0.01, +0.01)
+ -0.01  -0.01  1.0
source
ReferenceFrameRotations.smallangle_to_quatMethod
smallangle_to_quat(θx::Number, θy::Number, θz::Number)

Create a quaternion from three small rotations of angles θx, θy, and θz [rad] about the axes X, Y, and Z, respectively.

Note

The quaternion is always normalized.

Example

julia> smallangle_to_quat(+0.01, -0.01, +0.01)
 Quaternion{Float64}:
-  + 0.999963 + 0.00499981⋅i - 0.00499981⋅j + 0.00499981⋅k
source
ReferenceFrameRotations.smallangle_to_rotMethod
smallangle_to_rot([T,] θx::Number, θy::Number, θz::Number[; normalize = true])

Create a rotation description of type T from three small rotations of angles θx, θy, and θz [rad] about the axes X, Y, and Z, respectively.

The type T of the rotation description can be DCM or Quaternion. If the type T is not specified, then if defaults to DCM.

If T is DCM, then the resulting matrix will be orthonormalized using the orthonormalize function if the keyword normalize is true.

Example

julia> dcm = smallangle_to_rot(+0.01, -0.01, +0.01)
+  + 0.999963 + 0.00499981⋅i - 0.00499981⋅j + 0.00499981⋅k
source
ReferenceFrameRotations.smallangle_to_rotMethod
smallangle_to_rot([T,] θx::Number, θy::Number, θz::Number[; normalize = true])

Create a rotation description of type T from three small rotations of angles θx, θy, and θz [rad] about the axes X, Y, and Z, respectively.

The type T of the rotation description can be DCM or Quaternion. If the type T is not specified, then if defaults to DCM.

If T is DCM, then the resulting matrix will be orthonormalized using the orthonormalize function if the keyword normalize is true.

Example

julia> dcm = smallangle_to_rot(+0.01, -0.01, +0.01)
 DCM{Float64}:
   0.9999     0.00989903  0.010098
  -0.009999   0.999901    0.00989802
@@ -539,7 +539,7 @@
 
 julia> q = smallangle_to_rot(Quaternion, +0.01, -0.01, +0.01)
 Quaternion{Float64}:
-  + 0.999963 + 0.00499981⋅i - 0.00499981⋅j + 0.00499981⋅k
source
ReferenceFrameRotations.vectMethod
vect(q::Quaternion)

Return the vectorial or imaginary part of the quaternion q represented by a 3 × 1 vector of type SVector{3}.

See also: imag, real

Examples

julia> q = Quaternion(cosd(75), 0, sind(75), 0)
+  + 0.999963 + 0.00499981⋅i - 0.00499981⋅j + 0.00499981⋅k
source
ReferenceFrameRotations.vectMethod
vect(q::Quaternion)

Return the vectorial or imaginary part of the quaternion q represented by a 3 × 1 vector of type SVector{3}.

See also: imag, real

Examples

julia> q = Quaternion(cosd(75), 0, sind(75), 0)
 Quaternion{Float64}:
   + 0.258819 + 0.0⋅i + 0.965926⋅j + 0.0⋅k
 
@@ -547,4 +547,4 @@
 3-element StaticArraysCore.SVector{3, Float64} with indices SOneTo(3):
  0.0
  0.9659258262890683
- 0.0
source
+ 0.0
source
diff --git a/dev/man/composing_rotations/index.html b/dev/man/composing_rotations/index.html index 3d93e61..24ef686 100644 --- a/dev/man/composing_rotations/index.html +++ b/dev/man/composing_rotations/index.html @@ -34,4 +34,4 @@ 0.696707 0.717356 0.0 -0.717356 0.696707 0.0 0.0 0.0 1.0
julia> q ∘ DQuaternion{Float64}: - + 0.921061 + 0.0⋅i + 0.0⋅j + 0.389418⋅k + + 0.921061 + 0.0⋅i + 0.0⋅j + 0.389418⋅k diff --git a/dev/man/conversions/index.html b/dev/man/conversions/index.html index 49f7f63..630484a 100644 --- a/dev/man/conversions/index.html +++ b/dev/man/conversions/index.html @@ -175,4 +175,4 @@ ]3-element Vector{EulerAngleAxis}: EulerAngleAxis{Float64}: θ = 1.25664 rad, v = [1.0, 0.0, 0.0] EulerAngleAxis{Float64}: θ = 1.11896 rad, v = [0.768586, 0.521703, 0.370273] - EulerAngleAxis{Float64}: θ = 0.54 rad, v = [0.707107, 0.707107, 0.0] + EulerAngleAxis{Float64}: θ = 0.54 rad, v = [0.707107, 0.707107, 0.0] diff --git a/dev/man/dcm/index.html b/dev/man/dcm/index.html index 9bd2bde..b8af410 100644 --- a/dev/man/dcm/index.html +++ b/dev/man/dcm/index.html @@ -39,4 +39,4 @@ 0.816497 -0.492366 -0.301511
julia> Dn * Dn'DCM{Float64}: 1.0 -2.87528e-16 -9.03184e-16 -2.87528e-16 1.0 3.4516e-16 - -8.47673e-16 3.4516e-16 1.0
Warning

This function does not check if the columns of the input matrix span a three-dimensional space. If not, then the returned matrix should have NaN. Notice, however, that such input matrix is not a valid direction cosine matrix.

+ -8.47673e-16 3.4516e-16 1.0
Warning

This function does not check if the columns of the input matrix span a three-dimensional space. If not, then the returned matrix should have NaN. Notice, however, that such input matrix is not a valid direction cosine matrix.

diff --git a/dev/man/euler_angle_axis/index.html b/dev/man/euler_angle_axis/index.html index a21cbf1..3ea141c 100644 --- a/dev/man/euler_angle_axis/index.html +++ b/dev/man/euler_angle_axis/index.html @@ -28,4 +28,4 @@ Euler angle : -4.71239 rad (-270.0°) Euler axis : [1.73205, 1.73205, 1.73205]
julia> inv(ea)EulerAngleAxis{Float64}: Euler angle : 1.5708 rad (90.0°) - Euler axis : [-1.73205, -1.73205, -1.73205] + Euler axis : [-1.73205, -1.73205, -1.73205] diff --git a/dev/man/euler_angles/index.html b/dev/man/euler_angles/index.html index b9213eb..04913db 100644 --- a/dev/man/euler_angles/index.html +++ b/dev/man/euler_angles/index.html @@ -52,4 +52,4 @@ R(X) : 4.6 rad ( 263.561°)
julia> a * inv(a)EulerAngles{Float64}: R(X) : -1.92593e-34 rad (-1.10348e-32°) R(Y) : 0.0 rad ( 0.0°) - R(X) : 0.0 rad ( 0.0°)
Warning

All the operations related to Euler angles first convert them to DCM or Quaternions, and then the result is converted back to Euler angles. Hence, the performance will not be good.

+ R(X) : 0.0 rad ( 0.0°)
Warning

All the operations related to Euler angles first convert them to DCM or Quaternions, and then the result is converted back to Euler angles. Hence, the performance will not be good.

diff --git a/dev/man/inv_rotations/index.html b/dev/man/inv_rotations/index.html index a055b44..5ff9dac 100644 --- a/dev/man/inv_rotations/index.html +++ b/dev/man/inv_rotations/index.html @@ -11,4 +11,4 @@ -1.73278e-17 1.97327e-17 1.0
julia> q1 = angle_to_quat(0.5, 0.5, 0.5, :XYZ)Quaternion{Float64}: + 0.894463 + 0.291567⋅i + 0.172955⋅j + 0.291567⋅k
julia> q2 = inv_rotation(q1)Quaternion{Float64}: + 0.894463 - 0.291567⋅i - 0.172955⋅j - 0.291567⋅k
julia> q2 * q1Quaternion{Float64}: - + 1.0 + 0.0⋅i - 1.38778e-17⋅j + 0.0⋅k + + 1.0 + 0.0⋅i - 1.38778e-17⋅j + 0.0⋅k diff --git a/dev/man/kinematics/index.html b/dev/man/kinematics/index.html index 0cff76c..0a2da45 100644 --- a/dev/man/kinematics/index.html +++ b/dev/man/kinematics/index.html @@ -30,4 +30,4 @@ 0.0 0.0
julia> qba = angle_to_quat(0.5, 0, 0, :XYZ)Quaternion{Float64}: + 0.968912 + 0.247404⋅i + 0.0⋅j + 0.0⋅k
julia> dquat(qba, wba_b)Quaternion{Float64}: - - 0.00123702 + 0.00484456⋅i + 0.0⋅j + 0.0⋅k + - 0.00123702 + 0.00484456⋅i + 0.0⋅j + 0.0⋅k diff --git a/dev/man/quaternions/index.html b/dev/man/quaternions/index.html index 26b6931..c999303 100644 --- a/dev/man/quaternions/index.html +++ b/dev/man/quaternions/index.html @@ -121,4 +121,4 @@ vB = vect(qBA \ vA * qBA) # Equivalent to: vect(inv(qBA)*vA*qBA) -vB
Note

A SArray is returned instead of the usual Array. This is a static vector created by the package StaticArrays. Generally, you can treat this vector as any other one. The only downside is that you cannot modify individual components because it is immutable.

+vB
Note

A SArray is returned instead of the usual Array. This is a static vector created by the package StaticArrays. Generally, you can treat this vector as any other one. The only downside is that you cannot modify individual components because it is immutable.

diff --git a/dev/man/random/index.html b/dev/man/random/index.html index 9de0c42..736591a 100644 --- a/dev/man/random/index.html +++ b/dev/man/random/index.html @@ -1,11 +1,11 @@ Random rotations · Reference Frame Rotations

Random rotations

Sometimes it is necessary to generate random rotations. For example, if you are testing a stochastic system numerically, you need to perform a Monte Carlo simulation sampling the initial conditions. ReferenceFrameRotations.jl defines rand function for all rotation representations, which samples a random rotation uniformly in SO(3).

julia> rand(Quaternion)Quaternion{Float64}:
-  - 0.220663 + 0.683043⋅i + 0.1094⋅j + 0.687598⋅k
julia> rand(DCM)DCM{Float64}: - -0.563555 -0.102129 -0.819741 - 0.695 0.477765 -0.537322 - 0.44652 -0.872531 -0.198268
julia> rand(EulerAngles)EulerAngles{Float64}: - R(X) : 2.99978 rad ( 171.875°) - R(Z) : 5.39373 rad ( 309.038°) - R(Y) : 6.13685 rad ( 351.615°)
julia> rand(EulerAngleAxis)EulerAngleAxis{Float64}: - Euler angle : 1.85745 rad (106.424°) - Euler axis : [-0.286745, 0.459471, -0.840633]
+ + 0.634035 + 0.727788⋅i - 0.23233⋅j + 0.11978⋅k
julia> rand(DCM)DCM{Float64}: + 0.037107 -0.98752 0.153062 + 0.717369 0.132956 0.683889 + -0.695704 0.0844251 0.71335
julia> rand(EulerAngles)EulerAngles{Float64}: + R(Y) : 2.02137 rad ( 115.816°) + R(X) : 5.51361 rad ( 315.907°) + R(Z) : 4.80641 rad ( 275.387°)
julia> rand(EulerAngleAxis)EulerAngleAxis{Float64}: + Euler angle : 3.11904 rad (178.708°) + Euler axis : [0.111569, -0.223323, -0.968338]