Library
Documentation for ReferenceFrameRotations.jl.
ReferenceFrameRotations.ReferenceFrameRotation — Type
ReferenceFrameRotationRepresent the union of all supported rotation types.
Core.Tuple — Method
Tuple(dcm::DCM{T}) where {T} -> NTuple{9, T}Return the column-major elements of dcm as a tuple.
ReferenceFrameRotations.CRP — Type
struct CRP{T}Represent Classical Rodrigues Parameters (CRP).
Fields
q1::T: First dimensionless CRP component [-].q2::T: Second dimensionless CRP component [-].q3::T: Third dimensionless CRP component [-].
ReferenceFrameRotations.CRP — Method
CRP(v::AbstractVector) -> CRP
CRP(::UniformScaling{T}) where {T} -> CRP{T}Construct a CRP from the three-component vector v.
ReferenceFrameRotations.CRP — Method
CRP(q1::Any, q2::Any, q3::Any) -> CRPConstruct CRP coordinates q1, q2, and q3 [-] after promoting their types.
ReferenceFrameRotations.DCM — Type
struct DCM{T}Store a Direction Cosine Matrix (DCM) whose nine elements have type T.
Fields
data::NTuple{9, T}: Matrix elements in column-major order.
Examples
julia> DCM(1.0I)
DCM{Float64}:
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
julia> DCM([1 0 0; 0 -1 0; 0 0 -1])
DCM{Int64}:
1 0 0
0 -1 0
0 0 -1ReferenceFrameRotations.EulerAngleAxis — Type
struct EulerAngleAxis{T}Represent a 3D rotation with an Euler angle and axis.
Fields
a::T: The Euler angle [rad].v::SVector{3, T}: Vector aligned with the Euler axis; callers must provide a unit vector.
Examples
julia> EulerAngleAxis(pi / 3, [sqrt(2) / 2, sqrt(2) / 2, 0])
EulerAngleAxis{Float64}:
Euler angle : 1.0472 rad (60.0°)
Euler axis : [0.707107, 0.707107, 0.0]ReferenceFrameRotations.EulerAngleAxis — Method
EulerAngleAxis(a::Any, v::AbstractVector) -> EulerAngleAxisConstruct an Euler angle and axis from a [rad] and the three-component vector v. Do not assume that v is normalized; this constructor does not normalize it, so callers must provide a unit axis when a valid rotation representation is required.
ReferenceFrameRotations.EulerAngleConversion — Type
struct EulerAngleConversion{R}Enable conversion to Euler angles using the Julia API.
ReferenceFrameRotations.EulerAngles — Type
struct EulerAngles{T}Store three Euler 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.
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.
Examples
julia> EulerAngles(pi / 2, pi / 4, -pi, :XYZ)
EulerAngles{Float64}:
R(X) : 1.5708 rad ( 90.0°)
R(Y) : 0.785398 rad ( 45.0°)
R(Z) : -3.14159 rad (-180.0°)ReferenceFrameRotations.EulerAngles — Method
EulerAngles(a1::Any, a2::Any, a3::Any, rot_seq::Symbol = :ZYX) -> EulerAnglesConstruct Euler angles a1, a2, and a3 [rad] with rotation sequence rot_seq.
This constructor does not validate rot_seq. Conversions require it to be one of the supported rotation sequences listed for EulerAngles; otherwise, they throw an ArgumentError.
ReferenceFrameRotations.MRP — Type
struct MRP{T}Represent Modified Rodrigues Parameters (MRP).
Fields
q1::T: First dimensionless MRP component [-].q2::T: Second dimensionless MRP component [-].q3::T: Third dimensionless MRP component [-].
ReferenceFrameRotations.MRP — Method
MRP(v::AbstractVector) -> MRP
MRP(::UniformScaling{T}) where {T} -> MRP{T}Construct an MRP from the three-component vector v.
ReferenceFrameRotations.MRP — Method
MRP(q1::Any, q2::Any, q3::Any) -> MRPConstruct MRP coordinates q1, q2, and q3 [-] after promoting their types.
ReferenceFrameRotations.Quaternion — Type
struct Quaternion{T}Represent a quaternion with scalar-first components.
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.
Example
julia> Quaternion(cosd(45), sind(45), 0, 0)
Quaternion{Float64}:
+ 0.707107 + 0.707107⋅i + 0.0⋅j + 0.0⋅kReferenceFrameRotations.Quaternion — Method
Quaternion(q0::Any, q1::Any, q2::Any, q3::Any) -> Quaternion
Quaternion(v::AbstractVector) -> Quaternion
Quaternion(r::Number, v::AbstractVector) -> Quaternion
Quaternion(u::UniformScaling{T}) where {T} -> Quaternion{T}
Quaternion{T}(u::UniformScaling) where {T} -> Quaternion{T}
Quaternion(u::UniformScaling, q::Quaternion{T}) where {T} -> Quaternion{T}Create the following quaternion:
q0 + q1.i + q2.j + q3.kin which:
q0is the real part of the quaternion.q1is the X component of the quaternion vectorial part.q2is the Y component of the quaternion vectorial part.q3is the Z component of the quaternion vectorial part.
Examples
julia> Quaternion(1, 0, 0, 0)
Quaternion{Int64}:
+ 1 + 0⋅i + 0⋅j + 0⋅k
julia> Quaternion(1, 0, 0, 0.0)
Quaternion{Float64}:
+ 1.0 + 0.0⋅i + 0.0⋅j + 0.0⋅kQuaternion(v::AbstractVector) -> QuaternionIf the vector v has 3 components, then create a quaternion in which the real part is 0 and the vectorial or imaginary part has the same components of the vector v. In other words:
q = 0 + v[1].i + v[2].j + v[3].kOtherwise, if the vector v has 4 components, then create a quaternion in which the elements match those of the input vector:
q = v[1] + v[2].i + v[3].j + v[4].kExamples
julia> Quaternion([0, cosd(45), sind(45)])
Quaternion{Float64}:
+ 0.0 + 0.0⋅i + 0.707107⋅j + 0.707107⋅k
julia> Quaternion([cosd(45), 0, sind(45), 0])
Quaternion{Float64}:
+ 0.707107 + 0.0⋅i + 0.707107⋅j + 0.0⋅kQuaternion(r::Number, v::AbstractVector) -> QuaternionCreate a quaternion with real part r and vectorial or imaginary part v:
r + v[1].i + v[2].j + v[3].kThe quaternion type is obtained by promoting the type of r and the elements of v. The vector v must have exactly 3 components; otherwise, an ArgumentError is thrown.
Examples
julia> Quaternion(cosd(45), [0, sind(45), 0])
Quaternion{Float64}:
+ 0.707107 + 0.0⋅i + 0.707107⋅j + 0.0⋅kCreate the quaternion u.λ + 0.i + 0.j + 0.k.
If a quaternion is passed as in the sixth signature, then the new quaternion will have the same element type as it.
Examples
julia> Quaternion(I)
Quaternion{Bool}:
+ true + false⋅i + false⋅j + false⋅k
julia> Quaternion(1.0I)
Quaternion{Float64}:
+ 1.0 + 0.0⋅i + 0.0⋅j + 0.0⋅k
julia> q = Quaternion{Float32}(I)
Quaternion{Float32}:
+ 1.0 + 0.0⋅i + 0.0⋅j + 0.0⋅k
julia> Quaternion(I, q)
Quaternion{Float32}:
+ 1.0 + 0.0⋅i + 0.0⋅j + 0.0⋅kBase.:* — Method
*(v::AbstractVector, q::Quaternion) -> Quaternion
*(q::Quaternion, v::AbstractVector) -> QuaternionCompute 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
julia> v = [0, cosd(60), sind(60)]
3-element Vector{Float64}:
0.0
0.5
0.8660254037844386
julia> q * v
Quaternion{Float64}:
+ 0.0 + 0.0⋅i + 0.5⋅j + 0.866025⋅kBase.:* — Method
*(Θ₂::EulerAngles, Θ₁::EulerAngles) -> EulerAnglesCompose Θ₁ followed by Θ₂.
Represent the result with 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°)
R(Z) : 0.0 rad ( 0.0°)
julia> ea2 = EulerAngles(0, 0, deg2rad(25), :ZYX)
EulerAngles{Float64}:
R(Z) : 0.0 rad ( 0.0°)
R(Y) : 0.0 rad ( 0.0°)
R(X) : 0.436332 rad ( 25.0°)
julia> ea2 * ea1
EulerAngles{Float64}:
R(Z) : 0.0 rad ( 0.0°)
R(Y) : 0.0 rad ( 0.0°)
R(X) : 1.0472 rad ( 60.0°)Base.:* — Method
*(q1::Quaternion, q2::Quaternion) -> QuaternionCompute 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
julia> q2 = Quaternion(cosd(60), 0, sind(60), 0)
Quaternion{Float64}:
+ 0.5 + 0.0⋅i + 0.866025⋅j + 0.0⋅k
julia> q1 * q2
Quaternion{Float64}:
+ 0.0 + 0.0⋅i + 1.0⋅j + 0.0⋅k
julia> I * q1
Quaternion{Float64}:
+ 0.866025 + 0.0⋅i + 0.5⋅j + 0.0⋅kBase.:* — Method
*(av₂::EulerAngleAxis, av₁::EulerAngleAxis) -> EulerAngleAxisCompose av₁ followed by av₂.
Represent the result as an Euler angle and axis (see EulerAngleAxis). By convention, the output angle will always be in the range [0, π] [rad].
Require the vectors representing the axes in av₁ and av₂ to have unit length; this function neither verifies nor normalizes them.
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]
julia> av2 = EulerAngleAxis(deg2rad(22.5), [sqrt(2)/2, sqrt(2)/2, 0])
EulerAngleAxis{Float64}:
Euler angle : 0.392699 rad (22.5°)
Euler axis : [0.707107, 0.707107, 0.0]
julia> av1 * av2
EulerAngleAxis{Float64}:
Euler angle : 1.1781 rad (67.5°)
Euler axis : [0.707107, 0.707107, 0.0]Base.:+ — Method
+(qa::Quaternion, qb::Quaternion) -> QuaternionCompute 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
julia> q2 = Quaternion(0, cosd(45), 0, sind(45))
Quaternion{Float64}:
+ 0.0 + 0.707107⋅i + 0.0⋅j + 0.707107⋅k
julia> q1 + q2
Quaternion{Float64}:
+ 1.0 + 0.707107⋅i + 0.0⋅j + 0.707107⋅k
julia> q1 + I
Quaternion{Int64}:
+ 2 + 0⋅i + 0⋅j + 0⋅kBase.:- — Method
-(qa::Quaternion, qb::Quaternion) -> QuaternionCompute 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
julia> q2 = Quaternion(0, cosd(45), 0, sind(45))
Quaternion{Float64}:
+ 0.0 + 0.707107⋅i + 0.0⋅j + 0.707107⋅k
julia> q1 - q2
Quaternion{Float64}:
+ 1.0 - 0.707107⋅i + 0.0⋅j - 0.707107⋅k
julia> q1 - I
Quaternion{Int64}:
+ 0 + 0⋅i + 0⋅j + 0⋅kBase.:/ — Method
/(λ::Number, q::Quaternion) -> Quaternion
/(q::Quaternion, λ::Number) -> QuaternionCompute 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⋅kBase.:/ — Method
/(q1::Quaternion, q2::Quaternion) -> QuaternionCompute 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
julia> q2 = Quaternion(cosd(30), 0, sind(30), 0)
Quaternion{Float64}:
+ 0.866025 + 0.0⋅i + 0.5⋅j + 0.0⋅k
julia> q1 / q2
Quaternion{Float64}:
+ 0.707107 + 0.0⋅i + 0.707107⋅j + 0.0⋅k
julia> q1 / (2 * I)
Quaternion{Float64}:
+ 0.12941 + 0.0⋅i + 0.482963⋅j + 0.0⋅kBase.:\ — Method
\(v::AbstractVector, q::Quaternion) -> Quaternion
\(q::Quaternion, v::AbstractVector) -> QuaternionCompute 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
julia> v = [0, cosd(60), sind(60)]
3-element Vector{Float64}:
0.0
0.5
0.8660254037844386
julia> v \ q
Quaternion{Float64}:
+ 0.0 + 0.0⋅i - 0.5⋅j - 0.866025⋅kBase.:\ — Method
\(q1::Quaternion, q2::Quaternion) -> QuaternionCompute 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
julia> q2 = Quaternion(cosd(30), 0, sind(30), 0)
Quaternion{Float64}:
+ 0.866025 + 0.0⋅i + 0.5⋅j + 0.0⋅k
julia> q2 \ q1
Quaternion{Float64}:
+ 0.707107 + 0.0⋅i + 0.707107⋅j + 0.0⋅kBase.:≈ — Method
≈(q1::Quaternion, q2::Quaternion; kwargs...) -> BoolCompare corresponding components of q1 and q2 using isapprox.
The comparison is performed componentwise. Since the default atol is 0, a component that is (nearly) zero in one operand but exactly zero in the other makes the comparison fail. This differs from the norm-based semantics of isapprox for AbstractVector. Hence, pass atol explicitly when comparing rotations that may have near-zero components.
Keywords
kwargs...: Forwarded approximate-comparison keywords such asatolandrtol.
Base.conj — Method
conj(q::Quaternion) -> QuaternionCompute the conjugate of the quaternion q:
q0 - q1.i - q2.j - q3.kSee 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⋅kBase.convert — Method
convert(::Type{CRP}, c::CRP) -> CRP
convert(::Type{CRP}, a::ReferenceFrameRotation) -> CRP
convert(::Type{CRP{T}}, a::ReferenceFrameRotation) where {T} -> CRP{T}Convert rotation a to classical Rodrigues parameters, optionally changing its scalar type to T.
Base.convert — Method
convert(::Type{DCM}, a::ReferenceFrameRotation) -> DCM
convert(::Type{DCM{T}}, a::ReferenceFrameRotation) where {T} -> DCM{T}Convert rotation a to a direction cosine matrix, optionally converting its scalar type to T.
Base.convert — Method
convert(::Type{EulerAngleAxis}, a::EulerAngleAxis) -> EulerAngleAxis
convert(::Type{EulerAngleAxis}, a::ReferenceFrameRotation) -> EulerAngleAxis
convert(::Type{EulerAngleAxis{T}}, a::EulerAngleAxis) where {T} -> EulerAngleAxis{T}
convert(
::Type{EulerAngleAxis{T}},
a::ReferenceFrameRotation
) -> EulerAngleAxis{T}Convert rotation a to an Euler angle-axis representation.
Base.convert — Method
convert(::Type{EulerAngles}, a::EulerAngles) -> EulerAngles
convert(::Type{EulerAngles}, a::ReferenceFrameRotation) -> EulerAngles
convert(::Type{EulerAngles{T}}, a::EulerAngles) where {T} -> EulerAngles{T}
convert(::Type{EulerAngles{T}}, a::ReferenceFrameRotation) where {T} -> EulerAngles{T}Convert rotation a to Euler angles using the default :ZYX sequence, or preserve the sequence when a is already an EulerAngles value.
Base.convert — Method
convert(::Type{MRP}, m::MRP) -> MRP
convert(::Type{MRP}, a::ReferenceFrameRotation) -> MRP
convert(::Type{MRP{T}}, a::ReferenceFrameRotation) where {T} -> MRP{T}Convert rotation a to modified Rodrigues parameters, optionally converting its scalar type to T.
Base.convert — Method
convert(::Type{Quaternion}, q::Quaternion) -> Quaternion
convert(::Type{Quaternion}, a::ReferenceFrameRotation) -> Quaternion
convert(::Type{Quaternion{T}}, a::ReferenceFrameRotation) where {T} -> Quaternion{T}Convert rotation a to a scalar-first quaternion, optionally converting its scalar type to T.
Base.convert — Method
convert(::Type{CRP{T}}, c::CRP) where {T} -> CRP{T}Convert CRP c to scalar type T.
Base.convert — Method
convert(::Type{MRP{T}}, m::MRP) where {T} -> MRP{T}Convert MRP m to scalar type T.
Base.convert — Method
convert(::Type{Quaternion{T}}, q::Quaternion) where {T} -> Quaternion{T}Convert quaternion q to scalar type T.
Base.getindex — Method
getindex(dcm::DCM{T}, i::Int) where {T} -> TReturn an element of dcm using the indexing conventions provided by StaticArrays.
Base.imag — Method
imag(q::Quaternion{T}) -> SVector{3, T}Return the vectorial or imaginary part of the quaternion q represented by a 3 × 1 vector of type SVector{3}.
Examples
julia> q = Quaternion(cosd(75), 0, sind(75), 0)
Quaternion{Float64}:
+ 0.258819 + 0.0⋅i + 0.965926⋅j + 0.0⋅k
julia> imag(q)
3-element StaticArraysCore.SVector{3, Float64} with indices SOneTo(3):
0.0
0.9659258262890683
0.0Base.inv — Method
inv(Θ::EulerAngles) -> EulerAnglesReturn Euler angles representing 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°)
R(X) : 2.0944 rad ( 120.0°)
julia> inv(ea)
EulerAngles{Float64}:
R(X) : -2.0944 rad (-120.0°)
R(Y) : -0.523599 rad (-30.0°)
R(Z) : -1.0472 rad (-60.0°)Base.inv — Method
inv(q::Quaternion) -> QuaternionCompute the inverse of the quaternion q:
conj(q)
───────
|q|²See also: conj
Examples
julia> q = Quaternion(1, 0, cosd(75), sind(75))
Quaternion{Float64}:
+ 1.0 + 0.0⋅i + 0.258819⋅j + 0.965926⋅k
julia> inv(q)
Quaternion{Float64}:
+ 0.5 - 0.0⋅i - 0.12941⋅j - 0.482963⋅kBase.inv — Method
inv(av::EulerAngleAxis) -> EulerAngleAxisReturn the inverse rotation of the Euler angle and axis av.
Return an Euler angle 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]
julia> inv(av)
EulerAngleAxis{Float64}:
Euler angle : 0.349066 rad (20.0°)
Euler axis : [-0.707107, -0.0, -0.707107]
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]
julia> inv(av)
EulerAngleAxis{Float64}:
Euler angle : 0.349066 rad (20.0°)
Euler axis : [0.707107, 0.0, 0.707107]Base.isapprox — Method
isapprox(c1::CRP, c2::CRP; kwargs...) -> BoolCompare corresponding components of c1 and c2 using approximate equality.
The comparison is performed componentwise. Since the default atol is 0, a component that is (nearly) zero in one operand but exactly zero in the other makes the comparison fail. This differs from the norm-based semantics of isapprox for AbstractVector. Hence, pass atol explicitly when comparing rotations that may have near-zero components.
Keywords
kwargs...: Forwarded approximate-comparison keywords such asatolandrtol.
Base.isapprox — Method
isapprox(m1::MRP, m2::MRP; kwargs...) -> BoolCompare corresponding components of m1 and m2 using approximate equality.
The comparison is performed componentwise. Since the default atol is 0, a component that is (nearly) zero in one operand but exactly zero in the other makes the comparison fail. This differs from the norm-based semantics of isapprox for AbstractVector. Hence, pass atol explicitly when comparing rotations that may have near-zero components.
Keywords
kwargs...: Forwarded approximate-comparison keywords such asatolandrtol.
Base.setindex! — Method
setindex!(v::Vector{T}, c::CRP, I::UnitRange) where {T} -> Vector{T}Write the three components of c into v at the positions in I, mutating v.
Base.setindex! — Method
setindex!(v::Vector{T}, m::MRP, I::UnitRange) where {T} -> Vector{T}Write the three components of m into v at the positions in I, mutating v.
Base.setindex! — Method
setindex!(v::Vector{T}, q::Quaternion, I::UnitRange) where {T} -> Vector{T}Write the four components of q into v at the positions in I, mutating v.
LinearAlgebra.norm — Method
norm(c::CRP) -> NumberCompute the Euclidean norm of the CRP c.
LinearAlgebra.norm — Method
norm(m::MRP) -> NumberCompute the Euclidean norm of the MRP m.
LinearAlgebra.norm — Method
norm(q::Quaternion{T}) -> float(T)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.0ReferenceFrameRotations.angle_to_angle — Method
angle_to_angle(
θ₁::Number,
θ₂::Number,
θ₃::Number,
rot_seq_orig::Symbol,
rot_seq_dest::Symbol
) -> EulerAngles
angle_to_angle(Θ::EulerAngles, rot_seq_dest::Symbol) -> EulerAnglesConvert 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 can also be passed in 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°)
R(Y) : 0.785398 rad ( 45.0°)
R(Z) : -1.5708 rad (-90.0°)
julia> angle_to_angle(-pi / 2, 0, 0, :ZYX, :XYZ)
EulerAngles{Float64}:
R(X) : 0.0 rad ( 0.0°)
R(Y) : 0.0 rad ( 0.0°)
R(Z) : -1.5708 rad (-90.0°)
julia> Θ = EulerAngles(1, 2, 3, :XYX)
EulerAngles{Int64}:
R(X) : 1 rad ( 57.2958°)
R(Y) : 2 rad ( 114.592°)
R(X) : 3 rad ( 171.887°)
julia> angle_to_angle(Θ, :ZYZ)
EulerAngles{Float64}:
R(Z) : -2.70239 rad (-154.836°)
R(Y) : 1.46676 rad ( 84.0393°)
R(Z) : -1.05415 rad (-60.3984°)ReferenceFrameRotations.angle_to_angleaxis — Function
angle_to_angleaxis(
θ₁::Number,
θ₂::Number,
θ₃::Number,
rot_seq::Symbol = :ZYX
) -> EulerAngleAxis
angle_to_angleaxis(Θ::EulerAngles) -> EulerAngleAxisConvert 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, it defaults to :ZYX.
Example
julia> angle_to_angleaxis(1, 0, 0, :XYZ)
EulerAngleAxis{Float64}:
Euler angle : 1.0 rad (57.2958°)
Euler axis : [1.0, 0.0, 0.0]
julia> Θ = EulerAngles(1, 1, 1, :XYZ);
julia> angle_to_angleaxis(Θ)
EulerAngleAxis{Float64}:
Euler angle : 1.93909 rad (111.102°)
Euler axis : [0.692363, 0.203145, 0.692363]ReferenceFrameRotations.angle_to_crp — Function
angle_to_crp(θ₁::Number, θ₂::Number, θ₃::Number, rot_seq::Symbol = :ZYX) -> CRP
angle_to_crp(Θ::EulerAngles) -> CRPConvert the Euler angles θ₁, θ₂, and θ₃ [rad] with the rotation sequence rot_seq to classical Rodrigues parameters.
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, it defaults to :ZYX.
ReferenceFrameRotations.angle_to_dcm — Method
angle_to_dcm(θ::Number, rot_seq::Symbol) -> DCM
angle_to_dcm(θ₁::Number, θ₂::Number, rot_seq::Symbol) -> DCM
angle_to_dcm(θ₁::Number, θ₂::Number, θ₃::Number, rot_seq::Symbol = :ZYX) -> DCM
angle_to_dcm(Θ::EulerAngles) -> DCMCreate a direction cosine matrix that performs rotations (θ₁, θ₂, and θ₃) about the coordinate axes specified in rot_seq.
The input values of the original Euler angles can also be passed inside the structure Θ (see EulerAngles).
The rotation sequence is defined by a Symbol specifying the rotation axes. The possible values depend 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, where Ai is the DCM related to 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
0.0 6.12323e-17 1.0
0.0 -1.0 6.12323e-17
julia> angle_to_dcm(pi / 5, pi / 7, :YZ)
DCM{Float64}:
0.728899 0.433884 -0.529576
-0.351019 0.900969 0.25503
0.587785 0.0 0.809017
julia> angle_to_dcm(pi / 5, pi / 7, 0, :YZY)
DCM{Float64}:
0.728899 0.433884 -0.529576
-0.351019 0.900969 0.25503
0.587785 0.0 0.809017
julia> dcm = angle_to_dcm(pi / 2, pi / 3, pi / 4, :ZYX)
DCM{Float64}:
3.06162e-17 0.5 -0.866025
-0.707107 0.612372 0.353553
0.707107 0.612372 0.353553ReferenceFrameRotations.angle_to_mrp — Function
angle_to_mrp(θ₁::Number, θ₂::Number, θ₃::Number, rot_seq::Symbol = :ZYX) -> MRP
angle_to_mrp(Θ::EulerAngles) -> MRPConvert the Euler angles θ₁, θ₂, and θ₃ [rad] with the rotation sequence rot_seq to modified Rodrigues parameters.
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, it defaults to :ZYX.
ReferenceFrameRotations.angle_to_quat — Method
angle_to_quat(θ::Number, rot_seq::Symbol) -> Quaternion
angle_to_quat(θ₁::Number, θ₂::Number, rot_seq::Symbol) -> Quaternion
angle_to_quat(θ₁::Number, θ₂::Number, θ₃::Number, rot_seq::Symbol = :ZYX) -> Quaternion
angle_to_quat(Θ::EulerAngles) -> QuaternionCreate a quaternion that performs a set of rotations (θ₁, θ₂, θ₃) about the coordinate axes specified in rot_seq.
The input values can also be passed in the Θ structure (see EulerAngles).
The rotation sequence is defined by a Symbol specifying the rotation axes. The possible values depend 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
The element type of the new quaternion is obtained by promoting the types of the input angles to a float.
Remarks
This function assigns q = q1 * q2 * q3, where qi is the quaternion related to 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
julia> angle_to_quat(pi / 5, pi / 7, :YZ)
Quaternion{Float64}:
+ 0.927212 + 0.0687628⋅i + 0.301269⋅j + 0.21163⋅k
julia> angle_to_quat(pi / 5, pi / 7, 0, :YZX)
Quaternion{Float64}:
+ 0.927212 + 0.0687628⋅i + 0.301269⋅j + 0.21163⋅k
julia> angle_to_quat(pi / 2, pi / 3, pi / 4, :ZYX)
Quaternion{Float64}:
+ 0.701057 - 0.092296⋅i + 0.560986⋅j + 0.430459⋅kReferenceFrameRotations.angle_to_rot — Method
angle_to_rot(θ::Number, rot_seq::Symbol) -> DCM
angle_to_rot(θ₁::Number, θ₂::Number, rot_seq::Symbol) -> DCM
angle_to_rot(θ₁::Number, θ₂::Number, θ₃::Number, rot_seq::Symbol) -> DCM
angle_to_rot(::Type{DCM}, θ::Number, rot_seq::Symbol) -> DCM
angle_to_rot(::Type{Quaternion}, θ::Number, rot_seq::Symbol) -> Quaternion
angle_to_rot(::Type{DCM}, θ₁::Number, θ₂::Number, rot_seq::Symbol) -> DCM
angle_to_rot(::Type{Quaternion}, θ₁::Number, θ₂::Number, rot_seq::Symbol) -> Quaternion
angle_to_rot(::Type{DCM}, θ₁::Number, θ₂::Number, θ₃::Number, rot_seq::Symbol) -> DCM
angle_to_rot(
::Type{Quaternion},
θ₁::Number,
θ₂::Number,
θ₃::Number,
rot_seq::Symbol
) -> Quaternion
angle_to_rot(Θ::EulerAngles) -> DCM
angle_to_rot(::Type{Union{DCM, Quaternion}}, Θ::EulerAngles) -> Union{DCM, Quaternion}Create a rotation description of type T that performs rotations (θ₁, θ₂, and θ₃) about the coordinate axes specified in rot_seq.
The input values of the original Euler angles can also be passed inside the structure Θ (see EulerAngles).
The rotation sequence is defined by a Symbol specifying the rotation axes. The possible values depend 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)
DCM{Float64}:
0.809017 0.587785 0.0
-0.587785 0.809017 0.0
0.0 0.0 1.0
julia> quat = angle_to_rot(Quaternion, pi / 5, :Z)
Quaternion{Float64}:
+ 0.951057 + 0.0⋅i + 0.0⋅j + 0.309017⋅k
julia> dcm = angle_to_rot(pi / 5, pi / 7, :YZ)
DCM{Float64}:
0.728899 0.433884 -0.529576
-0.351019 0.900969 0.25503
0.587785 0.0 0.809017
julia> quat = angle_to_rot(Quaternion, pi / 5, pi / 7, :YZ)
Quaternion{Float64}:
+ 0.927212 + 0.0687628⋅i + 0.301269⋅j + 0.21163⋅k
julia> dcm = angle_to_rot(pi / 2, pi / 3, pi / 4, :ZYX)
DCM{Float64}:
3.06162e-17 0.5 -0.866025
-0.707107 0.612372 0.353553
0.707107 0.612372 0.353553
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⋅kReferenceFrameRotations.angleaxis_to_angle — Method
angleaxis_to_angle(θ::Number, v::AbstractVector, rot_seq::Symbol) -> EulerAngles
angleaxis_to_angle(av::EulerAngleAxis, rot_seq::Symbol) -> EulerAnglesConvert 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. The rotation sequence is required for both calling forms.
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°)ReferenceFrameRotations.angleaxis_to_crp — Method
angleaxis_to_crp(a::Number, v::AbstractVector) -> CRP
angleaxis_to_crp(av::EulerAngleAxis) -> CRPConvert the Euler angle a [rad] and Euler axis v to classical Rodrigues parameters.
Those values can also be passed inside the structure av (see EulerAngleAxis).
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> angleaxis_to_crp(pi / 2, [1, 0, 0])
CRP{Float64}:
X : + 1.0
Y : + 0.0
Z : + 0.0ReferenceFrameRotations.angleaxis_to_dcm — Method
angleaxis_to_dcm(a::Number, v::AbstractVector) -> DCM
angleaxis_to_dcm(av::EulerAngleAxis) -> DCMConvert the Euler angle a [rad] and Euler axis v to a DCM.
Those values can also be passed inside the structure av (see EulerAngleAxis).
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_dcm(pi / 2, v)
DCM{Float64}:
0.333333 0.910684 -0.244017
-0.244017 0.333333 0.910684
0.910684 -0.244017 0.333333
julia> ea = EulerAngleAxis(pi / 2, v);
julia> angleaxis_to_dcm(ea)
DCM{Float64}:
0.333333 0.910684 -0.244017
-0.244017 0.333333 0.910684
0.910684 -0.244017 0.333333ReferenceFrameRotations.angleaxis_to_mrp — Method
angleaxis_to_mrp(a::Number, v::AbstractVector) -> MRP
angleaxis_to_mrp(av::EulerAngleAxis) -> MRPConvert the Euler angle a [rad] and Euler axis v to modified Rodrigues parameters.
Those values can also be passed inside the structure av (see EulerAngleAxis).
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> angleaxis_to_mrp(pi / 2, [1, 0, 0])
MRP{Float64}:
X : + 0.414214
Y : + 0.0
Z : + 0.0ReferenceFrameRotations.angleaxis_to_quat — Method
angleaxis_to_quat(θ::Number, v::AbstractVector) -> Quaternion
angleaxis_to_quat(angleaxis::EulerAngleAxis) -> QuaternionConvert the Euler angle θ [rad] and Euler axis v to a quaternion.
Those values can also be passed inside the structure angleaxis (see EulerAngleAxis).
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⋅kReferenceFrameRotations.crp_to_angle — Function
crp_to_angle(c::CRP, rot_seq::Symbol = :ZYX) -> EulerAnglesConvert CRP c 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, it defaults to :ZYX.
Examples
julia> c = CRP(0.5, 0, 0)
CRP{Float64}:
X : + 0.5
Y : + 0.0
Z : + 0.0
julia> crp_to_angle(c, :XYZ)
EulerAngles{Float64}:
R(X) : 0.927295 rad ( 53.1301°)
R(Y) : 0.0 rad ( 0.0°)
R(Z) : 0.0 rad ( 0.0°)ReferenceFrameRotations.crp_to_angleaxis — Method
crp_to_angleaxis(c::CRP) -> EulerAngleAxisConvert the CRP c to an Euler angle and axis representation (see EulerAngleAxis). By convention, the Euler angle will be kept between [0, π] rad.
Examples
julia> c = CRP(0.5, 0, 0)
CRP{Float64}:
X : + 0.5
Y : + 0.0
Z : + 0.0
julia> crp_to_angleaxis(c)
EulerAngleAxis{Float64}:
Euler angle : 0.927295 rad (53.1301°)
Euler axis : [1.0, 0.0, 0.0]ReferenceFrameRotations.crp_to_dcm — Method
crp_to_dcm(c::CRP) -> DCMConvert the CRP c to a Direction Cosine Matrix (DCM).
Examples
julia> c = CRP(0.5, 0, 0)
CRP{Float64}:
X : + 0.5
Y : + 0.0
Z : + 0.0
julia> crp_to_dcm(c)
DCM{Float64}:
1.0 0.0 0.0
0.0 0.6 0.8
0.0 -0.8 0.6ReferenceFrameRotations.crp_to_mrp — Method
crp_to_mrp(c::CRP) -> MRPConvert CRP c to MRP.
Examples
julia> c = CRP(0.5, 0, 0)
CRP{Float64}:
X : + 0.5
Y : + 0.0
Z : + 0.0
julia> crp_to_mrp(c)
MRP{Float64}:
X : + 0.236068
Y : + 0.0
Z : + 0.0ReferenceFrameRotations.crp_to_quat — Method
crp_to_quat(c::CRP) -> QuaternionConvert CRP c to a quaternion.
Remarks
By convention, the real part of the quaternion will always be positive. Moreover, the function does not check if c is a valid classical Rodrigues parameter vector. This must be handled by the user.
Example
julia> c = CRP(0.5, 0, 0)
CRP{Float64}:
X : + 0.5
Y : + 0.0
Z : + 0.0
julia> crp_to_quat(c)
Quaternion{Float64}:
+ 0.894427 + 0.447214⋅i + 0.0⋅j + 0.0⋅kReferenceFrameRotations.dcm_to_angle — Method
dcm_to_angle(dcm::DCM, rot_seq::Symbol = :ZYX) -> EulerAnglesConvert 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, 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 gimbal lock. 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}:
R(X) : 1.5708 rad ( 90.0°)
R(Y) : 0.0 rad ( 0.0°)
R(Z) : 0.0 rad ( 0.0°)
julia> D = angle_to_dcm(1, -pi / 2, 2, :ZYX);
julia> dcm_to_angle(D, :ZYX)
EulerAngles{Float64}:
R(Z) : 3.0 rad ( 171.887°)
R(Y) : -1.5708 rad (-90.0°)
R(X) : 0.0 rad ( 0.0°)
julia> D = angle_to_dcm(1, :X) * angle_to_dcm(2, :X);
julia> dcm_to_angle(D, :XYX)
EulerAngles{Float64}:
R(X) : 3.0 rad ( 171.887°)
R(Y) : 0.0 rad ( 0.0°)
R(X) : 0.0 rad ( 0.0°)ReferenceFrameRotations.dcm_to_angleaxis — Method
dcm_to_angleaxis(dcm::DCM) -> EulerAngleAxisConvert the dcm to an Euler angle and axis representation.
Return an angle in the interval [0, π] [rad] by convention.
If dcm is the identity, the rotation angle is 0 and the Euler axis is undefined. In this case, return the zero vector [0, 0, 0] as the axis.
If the rotation is a half turn (θ = π), then v and -v describe exactly the same rotation. Hence, the sign of the returned axis is arbitrary.
Remarks
The conversion is performed through the quaternion representation, which is numerically well conditioned for every rotation angle, including θ near π.
ReferenceFrameRotations.dcm_to_crp — Method
dcm_to_crp(dcm::DCM) -> CRPConvert DCM dcm to CRP.
ReferenceFrameRotations.dcm_to_mrp — Method
dcm_to_mrp(dcm::DCM) -> MRPConvert DCM dcm to MRP.
ReferenceFrameRotations.dcm_to_quat — Method
dcm_to_quat(dcm::DCM) -> QuaternionConvert 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 nonnegative (and is zero for exact half-turns). Moreover, the function does not check if dcm is a valid direction cosine matrix. This must be handled 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⋅kReferences
- [1]: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/
ReferenceFrameRotations.dcrp — Method
dcrp(c::CRP, wba_b::AbstractVector) -> CRPCompute the time derivative of CRP c that rotates 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 [rad/s] [1].
Example
julia> c = CRP(0.0, 0.0, 0.0)
CRP{Float64}:
X : + 0.0
Y : + 0.0
Z : + 0.0
julia> dcrp(c, [1.0, 0.0, 0.0])
CRP{Float64}:
X : + 0.5
Y : + 0.0
Z : + 0.0References
- [1] Schaub, H.; Junkins, J. L (1996). Stereographic Orientation Parameters for Attitude Dynamics: A Generalization of the Rodrigues Parameters. In: Journal of the Astronautical Sciences, Vol. 44, No. 1, pp. 1 – 19.
ReferenceFrameRotations.ddcm — Method
ddcm(Dba::DCM, wba_b::AbstractArray) -> SMatrix{3, 3}Compute the time derivative of Dba that rotates 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 [rad/s].
Example
julia> D = DCM(1.0I);
julia> ddcm(D, [1, 0, 0])
3×3 StaticArraysCore.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
0.0 0.0 0.0
0.0 0.0 1.0
0.0 -1.0 0.0ReferenceFrameRotations.dmrp — Method
dmrp(m::MRP, wba_b::AbstractVector) -> MRPCompute the time derivative of MRP m that rotates 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 [rad/s] [1].
Example
julia> m = MRP(0.0, 0.0, 0.0)
MRP{Float64}:
X : + 0.0
Y : + 0.0
Z : + 0.0
julia> dmrp(m, [1.0, 0.0, 0.0])
MRP{Float64}:
X : + 0.25
Y : + 0.0
Z : + 0.0References
- [1] Schaub, H.; Junkins, J. L (1996). Stereographic Orientation Parameters for Attitude Dynamics: A Generalization of the Rodrigues Parameters. In: Journal of the Astronautical Sciences, Vol. 44, No. 1, pp. 1 – 19.
ReferenceFrameRotations.dquat — Method
dquat(qba::Quaternion, wba_b::AbstractVector) -> QuaternionCompute the time derivative of quaternion qba that rotates 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 [rad/s].
Examples
julia> q = Quaternion(1.0I);
julia> dquat(q,[1;0;0])
Quaternion{Float64}:
- 0.0 + 0.5⋅i + 0.0⋅j + 0.0⋅kReferenceFrameRotations.inv_rotation — Method
inv_rotation(R::ReferenceFrameRotation) -> ReferenceFrameRotationCompute the inverse rotation of R, which can be:
- A direction cosine matrix (
DCM); - An Euler angle and axis (
EulerAngleAxis); - A set of Euler angles (
EulerAngles); - A quaternion (
Quaternion); - Classical Rodrigues parameters (
CRP); or - Modified Rodrigues parameters (
MRP).
The output will have the same type as R, except that an EulerAngleAxis is promoted to a floating-point element type.
If R is a DCM, then its transpose is computed instead of its inverse to reduce the computational burden. The two are equal if the DCM is orthonormal. This must be verified by the user.
If R is a quaternion, then its conjugate is computed instead of its inverse to reduce the computational burden. The two are equal if the quaternion has unit norm. This must be verified by the user.
Example
julia> D = angle_to_dcm(pi / 3, pi / 4, pi / 5, :ZYX);
julia> inv_rotation(D)
DCM{Float64}:
0.353553 -0.492816 0.795068
0.612372 0.764452 0.201527
-0.707107 0.415627 0.572061
julia> ea = EulerAngleAxis(30 * pi / 180, [1, 0, 0]);
julia> inv_rotation(ea)
EulerAngleAxis{Float64}:
Euler angle : 0.523599 rad (30.0°)
Euler axis : [-1.0, -0.0, -0.0]
julia> Θ = EulerAngles(-pi / 3, -pi / 2, -pi, :YXZ);
julia> inv_rotation(Θ)
EulerAngles{Float64}:
R(Z) : 3.14159 rad ( 180.0°)
R(X) : 1.5708 rad ( 90.0°)
R(Y) : 1.0472 rad ( 60.0°)
julia> q = angle_to_quat(pi / 3, pi / 4, pi / 5, :ZYX);
julia> inv_rotation(q)
Quaternion{Float64}:
+ 0.820071 - 0.0652687⋅i - 0.45794⋅j - 0.336918⋅kReferenceFrameRotations.mrp_to_angle — Function
mrp_to_angle(m::MRP, rot_seq::Symbol = :ZYX) -> EulerAnglesConvert MRP m 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, it defaults to :ZYX.
Examples
julia> m = MRP(0.5, 0, 0)
MRP{Float64}:
X : + 0.5
Y : + 0.0
Z : + 0.0
julia> mrp_to_angle(m, :XYZ)
EulerAngles{Float64}:
R(X) : 1.85459 rad ( 106.26°)
R(Y) : 0.0 rad ( 0.0°)
R(Z) : 0.0 rad ( 0.0°)ReferenceFrameRotations.mrp_to_angleaxis — Method
mrp_to_angleaxis(m::MRP) -> EulerAngleAxisConvert the MRP m to an Euler angle and axis representation (see EulerAngleAxis). By convention, the Euler angle will be kept between [0, π] rad.
Examples
julia> m = MRP(0.5, 0, 0)
MRP{Float64}:
X : + 0.5
Y : + 0.0
Z : + 0.0
julia> mrp_to_angleaxis(m)
EulerAngleAxis{Float64}:
Euler angle : 1.85459 rad (106.26°)
Euler axis : [1.0, 0.0, 0.0]ReferenceFrameRotations.mrp_to_crp — Method
mrp_to_crp(m::MRP) -> CRPConvert MRP m to CRP.
Examples
julia> m = MRP(0.5, 0, 0)
MRP{Float64}:
X : + 0.5
Y : + 0.0
Z : + 0.0
julia> mrp_to_crp(m)
CRP{Float64}:
X : + 1.33333
Y : + 0.0
Z : + 0.0ReferenceFrameRotations.mrp_to_dcm — Method
mrp_to_dcm(m::MRP) -> DCMConvert MRP m to a Direction Cosine Matrix (DCM).
Examples
julia> m = MRP(0.5, 0, 0)
MRP{Float64}:
X : + 0.5
Y : + 0.0
Z : + 0.0
julia> mrp_to_dcm(m)
DCM{Float64}:
1.0 0.0 0.0
0.0 -0.28 0.96
0.0 -0.96 -0.28ReferenceFrameRotations.mrp_to_quat — Method
mrp_to_quat(m::MRP) -> QuaternionConvert MRP m to a quaternion.
Remarks
The real part of the resulting quaternion is positive if |m| < 1 and negative if |m| > 1 (the shadow MRP set). Moreover, the function does not check if m is a valid modified Rodrigues parameter vector. This must be handled by the user.
Example
julia> m = MRP(0.5, 0, 0)
MRP{Float64}:
X : + 0.5
Y : + 0.0
Z : + 0.0
julia> mrp_to_quat(m)
Quaternion{Float64}:
+ 0.6 + 0.8⋅i + 0.0⋅j + 0.0⋅kReferenceFrameRotations.orthonormalize — Method
orthonormalize(dcm::DCM) -> DCMPerform the Gram-Schmidt orthonormalization process on the dcm and return the new matrix.
This function does not check if the columns of the input matrix span a three-dimensional space. If not, then the returned matrix will contain NaNs. Notice, however, that such input matrix is not a valid direction cosine matrix.
The Gram-Schmidt process preserves the handedness of the input matrix. Hence, this function does not restore det(dcm) == +1: if the input matrix is improper, the returned matrix is orthonormal but also improper.
Example
julia> D = DCM(3I);
julia> orthonormalize(D)
DCM{Float64}:
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0ReferenceFrameRotations.quat_to_angle — Function
quat_to_angle(q::Quaternion, rot_seq::Symbol = :ZYX) -> EulerAnglesConvert 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, 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°)ReferenceFrameRotations.quat_to_angleaxis — Method
quat_to_angleaxis(q::Quaternion) -> EulerAngleAxisConvert the quaternion q to an Euler angle and axis representation (see EulerAngleAxis). By convention, keep the Euler angle between [0, π] [rad].
If q is the identity rotation, the Euler axis is undefined. In this case, return the zero vector [0, 0, 0] as the axis.
If the rotation is a half turn (θ = π), then v and -v describe exactly the same rotation. Hence, the sign of the returned axis is arbitrary.
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]ReferenceFrameRotations.quat_to_crp — Method
quat_to_crp(q::Quaternion) -> CRPConvert Quaternion q to CRP.
ReferenceFrameRotations.quat_to_dcm — Method
quat_to_dcm(q::Quaternion) -> DCMConvert 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.707107ReferenceFrameRotations.quat_to_mrp — Method
quat_to_mrp(q::Quaternion) -> MRPConvert Quaternion q to MRP.
ReferenceFrameRotations.shadow_rotation — Method
shadow_rotation(c::CRP) -> CRPReturn the shadow rotation of the CRP c.
The shadow rotation of a CRP is the rotation itself: c.
ReferenceFrameRotations.shadow_rotation — Method
shadow_rotation(m::MRP) -> MRPReturn the shadow rotation -m / |m|² of the MRP m. It represents the same rotation as m, and its norm is the reciprocal of the norm of m. Hence, a unit MRP maps to its antipode.
The shadow set is undefined for the zero MRP, for which this function throws a DomainError. For nonzero inputs, scalar types whose reciprocal remains in the same type, such as Rational and BigFloat, are preserved.
ReferenceFrameRotations.smallangle_to_dcm — Method
smallangle_to_dcm(θx::Number, θy::Number, θz::Number; kwargs...) -> DCMCreate 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, the matrix will be normalized using the function orthonormalize.
Keywords
normalize::Bool: Orthonormalize the resulting matrix. (Default:true)
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
-0.009999 -0.009998 0.9999
julia> smallangle_to_dcm(+0.01, -0.01, +0.01; normalize = false)
DCM{Float64}:
1.0 0.01 0.01
-0.01 1.0 0.01
-0.01 -0.01 1.0ReferenceFrameRotations.smallangle_to_quat — Method
smallangle_to_quat(θx::Number, θy::Number, θz::Number) -> QuaternionCreate a quaternion from three small rotations of angles θx, θy, and θz [rad] about the axes X, Y, and Z, respectively.
Example
julia> smallangle_to_quat(+0.01, -0.01, +0.01)
Quaternion{Float64}:
+ 0.999963 + 0.00499981⋅i - 0.00499981⋅j + 0.00499981⋅kReferenceFrameRotations.smallangle_to_rot — Method
smallangle_to_rot(θx::Number, θy::Number, θz::Number; kwargs...) -> DCM
smallangle_to_rot(::Type{DCM}, θx::Number, θy::Number, θz::Number; kwargs...) -> DCM
smallangle_to_rot(::Type{Quaternion}, θx::Number, θy::Number, θz::Number) -> QuaternionCreate 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, it defaults to DCM.
If T is DCM, orthonormalize the resulting matrix using orthonormalize function if the keyword normalize is true.
Keywords
normalize::Bool: Orthonormalize a DCM result whentrue. (Default: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
-0.009999 -0.009998 0.9999
julia> dcm = smallangle_to_rot(+0.01, -0.01, +0.01; normalize = false)
DCM{Float64}:
1.0 0.01 0.01
-0.01 1.0 0.01
-0.01 -0.01 1.0
julia> q = smallangle_to_rot(Quaternion, +0.01, -0.01, +0.01)
Quaternion{Float64}:
+ 0.999963 + 0.00499981⋅i - 0.00499981⋅j + 0.00499981⋅kReferenceFrameRotations.vect — Method
vect(c::CRP) -> SVector{3, T}Return the vector definition of the CRP c:
[q1, q2, q3]ReferenceFrameRotations.vect — Method
vect(m::MRP) -> SVector{3, T}Return the vector definition of the MRP m:
[q1, q2, q3]ReferenceFrameRotations.vect — Method
vect(q::Quaternion{T}) -> SVector{3, T}Return the vectorial or imaginary part of the quaternion q represented by a 3 × 1 vector of type SVector{3, T}.
Examples
julia> q = Quaternion(cosd(75), 0, sind(75), 0)
Quaternion{Float64}:
+ 0.258819 + 0.0⋅i + 0.965926⋅j + 0.0⋅k
julia> vect(q)
3-element StaticArraysCore.SVector{3, Float64} with indices SOneTo(3):
0.0
0.9659258262890683
0.0