Skip to content

Commit a903d1e

Browse files
committed
🎨 Apply the BlueStyle and improve docstrings
1 parent 8ddfa5a commit a903d1e

59 files changed

Lines changed: 721 additions & 1097 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/ReferenceFrameRotations.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ using StaticArrays
1717
# Re-export `I` from LinearAlgebra.
1818
export I
1919

20-
################################################################################
21-
# Types & Conversions
22-
################################################################################
20+
############################################################################################
21+
# Types and Conversions #
22+
############################################################################################
2323

2424
include("types.jl")
2525

26-
################################################################################
27-
# Constants
28-
################################################################################
26+
############################################################################################
27+
# Constants #
28+
############################################################################################
2929

3030
# Pre-defined crayons.
3131
const _reset_crayon = Crayon(reset = true)
@@ -41,9 +41,9 @@ const _g = _crayon_g
4141
const _y = _crayon_y
4242
const _u = _crayon_u
4343

44-
################################################################################
45-
# Includes
46-
################################################################################
44+
############################################################################################
45+
# Includes #
46+
############################################################################################
4747

4848
include("angle.jl")
4949
include("angleaxis.jl")

src/angle.jl

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1+
## Description #############################################################################
22
#
3-
# Description
4-
# ==============================================================================
3+
# Functions related to the Euler angles.
54
#
6-
# Functions related to the Euler angles.
7-
#
8-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
5+
############################################################################################
96

10-
################################################################################
11-
# Operations
12-
################################################################################
7+
############################################################################################
8+
# Operations #
9+
############################################################################################
1310

1411
"""
15-
*(Θ₂::EulerAngles, Θ₁::EulerAngles)
12+
*(Θ₂::EulerAngles, Θ₁::EulerAngles) -> EulerAngles
1613
1714
Compute the composed rotation of `Θ₁ -> Θ₂`.
1815
@@ -51,13 +48,12 @@ EulerAngles{Float64}:
5148
end
5249

5350
"""
54-
inv(Θ::EulerAngles)
51+
inv(Θ::EulerAngles) -> EulerAngles
5552
5653
Return the Euler angles that represent the inverse rotation of `Θ`.
5754
58-
The rotation sequence of the result will be the inverse of the input. Hence, if
59-
the input rotation sequence is, for example, `:XYZ`, then the result will be
60-
represented using `:ZYX`.
55+
The rotation sequence of the result will be the inverse of the input. Hence, if the input
56+
rotation sequence is, for example, `:XYZ`, then the result will be represented using `:ZYX`.
6157
6258
# Examples
6359
@@ -97,9 +93,9 @@ function inv(Θ::EulerAngles)
9793
return EulerAngles(-Θ.a3, -Θ.a2, -Θ.a1, inv_rot_seq)
9894
end
9995

100-
################################################################################
101-
# IO
102-
################################################################################
96+
############################################################################################
97+
# IO #
98+
############################################################################################
10399

104100
function show(io::IO, Θ::EulerAngles{T}) where T
105101
# Get if `io` request a compact printing, defaulting to true.
@@ -166,9 +162,9 @@ function show(io::IO, mime::MIME"text/plain", Θ::EulerAngles{T}) where T
166162
return nothing
167163
end
168164

169-
################################################################################
170-
# Julia API
171-
################################################################################
165+
############################################################################################
166+
# Julia API #
167+
############################################################################################
172168

173169
Base.eltype(::Type{EulerAngles{T}}) where T = T
174170

src/angleaxis.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1+
## Description #############################################################################
22
#
3-
# Description
4-
# ==============================================================================
3+
# Functions related to the Euler angle and axis.
54
#
6-
# Functions related to the Euler angle and axis.
7-
#
8-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
5+
############################################################################################
96

10-
################################################################################
11-
# Operations
12-
################################################################################
7+
############################################################################################
8+
# Operations #
9+
############################################################################################
1310

1411
"""
15-
*(av₂::EulerAngleAxis{T1}, av₁::EulerAngleAxis{T2}) where {T1,T2}
12+
*(av₂::EulerAngleAxis{T1}, av₁::EulerAngleAxis{T2}) where {T1, T2} -> EulerAngleAxis{T3}
1613
1714
Compute the composed rotation of `av₁ -> av₂`.
1815
@@ -23,6 +20,10 @@ range `[0, π] rad`.
2320
Notice that the vector representing the axis in `av₁` and `av₂` must be unitary.
2421
This function neither verifies this nor normalizes the vector.
2522
23+
!!! note
24+
25+
The output type `T3` is obtained by promoting `T1` and `T2` to a float.
26+
2627
# Examples
2728
2829
```jldoctest
@@ -80,12 +81,11 @@ function *(av₂::EulerAngleAxis{T1}, av₁::EulerAngleAxis{T2}) where {T1, T2}
8081
end
8182

8283
"""
83-
inv(av::EulerAngleAxis)
84+
inv(av::EulerAngleAxis) -> EulerAngleAxis
8485
8586
Compute the inverse rotation of the Euler angle and axis `av`.
8687
87-
The Euler angle returned by this function will always be in the interval `[0, π]
88-
rad`.
88+
The Euler angle returned by this function will always be in the interval `[0, π]` rad.
8989
9090
# Examples
9191
@@ -126,9 +126,9 @@ EulerAngleAxis{Float64}:
126126
return EulerAngleAxis(θ, s * av.v)
127127
end
128128

129-
################################################################################
130-
# IO
131-
################################################################################
129+
############################################################################################
130+
# IO #
131+
############################################################################################
132132

133133
function show(io::IO, av::EulerAngleAxis{T}) where T
134134
# Get if `io` request a compact printing, defaulting to true.
@@ -180,9 +180,9 @@ function show(io::IO, mime::MIME"text/plain", av::EulerAngleAxis{T}) where T
180180
return nothing
181181
end
182182

183-
################################################################################
184-
# Julia API
185-
################################################################################
183+
############################################################################################
184+
# Julia API #
185+
############################################################################################
186186

187187
Base.eltype(::Type{EulerAngleAxis{T}}) where T = T
188188

src/compose_rotations.jl

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1+
## Description #############################################################################
22
#
3-
# Description
4-
# ==============================================================================
3+
# Generic function to compose rotations.
54
#
6-
# Generic function to compose rotations.
7-
#
8-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
5+
############################################################################################
96

107
export compose_rotation
118

12-
################################################################################
13-
# Compose Rotations
14-
################################################################################
9+
############################################################################################
10+
# Compose Rotations #
11+
############################################################################################
1512

1613
"""
17-
compose_rotation(R1, [, R2, R3, R4, R5, ...])
14+
compose_rotation(R1::T, [, R2::T, R3::T, R4::T, R5::T, ...]) -> T
1815
19-
Compute a composed rotation using the rotations `R1`, `R2`, `R3`, `R4`, ..., in
20-
the following order:
16+
Compute a composed rotation using the rotations `R1`, `R2`, `R3`, `R4`, ..., in the
17+
following order:
2118
2219
First rotation
2320
|
@@ -34,8 +31,7 @@ The rotations can be described by:
3431
- A set of Euler angles ([`EulerAngles`](@ref)); or
3532
- A quaternion ([`Quaternion`](@ref)).
3633
37-
Notice, however, that all rotations **must be** of the same type (DCM or
38-
quaternion).
34+
Notice, however, that all rotations **must be** of the same type (DCM or quaternion).
3935
4036
The output will have the same type as the inputs.
4137
@@ -98,13 +94,9 @@ end
9894
#
9995
# https://discourse.julialang.org/t/improve-the-performance-of-multiplication-of-an-arbitrary-number-of-matrices/10835/24
10096

101-
# Operator: ∘
102-
# ==============================================================================
97+
# == Operator: ∘ ===========================================================================
10398

104-
function (R2::T1, R1::T2) where {
105-
T1<:ReferenceFrameRotation,
106-
T2<:ReferenceFrameRotation
107-
}
99+
function (R2::T1, R1::T2) where {T1<:ReferenceFrameRotation, T2<:ReferenceFrameRotation}
108100
R1c = convert(T1, R1)
109101
return compose_rotation(R1c, R2)
110102
end

src/conversions/angle_to_angle.jl

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1+
## Description #############################################################################
22
#
3-
# Description
4-
# ==============================================================================
3+
# Functions related to the conversion between Euler angles.
54
#
6-
# Functions related to the conversion between Euler angles.
7-
#
8-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
5+
############################################################################################
96

107
export angle_to_angle
118

129
"""
13-
angle_to_angle(θ₁::Number, θ₂::Number, θ₃::Number, rot_seq_orig::Symbol, rot_seq_dest::Symbol)
14-
angle_to_angle(Θ::EulerAngles, rot_seq_dest::Symbol)
10+
angle_to_angle(θ₁::Number, θ₂::Number, θ₃::Number, rot_seq_orig::Symbol, rot_seq_dest::Symbol) -> EulerAngles
11+
angle_to_angle(Θ::EulerAngles, rot_seq_dest::Symbol) -> EulerAngles
1512
1613
Convert the Euler angles `θ₁`, `θ₂`, and `θ₃` [rad] with the rotation sequence
17-
`rot_seq_orig` to a new set of Euler angles with rotation sequence
18-
`rot_seq_dest`.
14+
`rot_seq_orig` to a new set of Euler angles with rotation sequence `rot_seq_dest`.
1915
20-
The input values of the origin Euler angles can also be passed inside the
21-
structure `Θ` (see [`EulerAngles`](@ref)).
16+
The input values of the origin Euler angles can also be passed inside the structure `Θ` (see
17+
[`EulerAngles`](@ref)).
2218
23-
The rotation sequence is defined by a `:Symbol`. The possible values are:
24-
`:XYX`, `XYZ`, `:XZX`, `:XZY`, `:YXY`, `:YXZ`, `:YZX`, `:YZY`, `:ZXY`, `:ZXZ`,
25-
`:ZYX`, and `:ZYZ`.
19+
The rotation sequence is defined by a `:Symbol`. The possible values are: `:XYX`, `XYZ`,
20+
`:XZX`, `:XZY`, `:YXY`, `:YXZ`, `:YZX`, `:YZY`, `:ZXY`, `:ZXZ`, `:ZYX`, and `:ZYZ`.
2621
2722
# Example
2823

src/conversions/angle_to_angleaxis.jl

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1+
## Description #############################################################################
22
#
3-
# Description
4-
# ==============================================================================
3+
# Functions related to the conversion from Euler angle to Euler angle and axis.
54
#
6-
# Functions related to the conversion from Euler angle to Euler angle and
7-
# axis.
8-
#
9-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
5+
############################################################################################
106

117
export angle_to_angleaxis
128

139
"""
14-
angle_to_angleaxis(θ₁::Number, θ₂::Number, θ₃::Number, rot_seq::Symbol = :ZYX)
15-
angle_to_angleaxis(Θ::EulerAngles)
10+
angle_to_angleaxis(θ₁::Number, θ₂::Number, θ₃::Number, rot_seq::Symbol = :ZYX) -> EulerAngleAxis
11+
angle_to_angleaxis(Θ::EulerAngles) -> EulerAngleAxis
1612
17-
Convert the Euler angles `θ₁`, `θ₂`, and `θ₃` [rad] with the rotation sequence
18-
`rot_seq` to an Euler angle and axis representation.
13+
Convert the Euler angles `θ₁`, `θ₂`, and `θ₃` [rad] with the rotation sequence `rot_seq` to
14+
an Euler angle and axis representation.
1915
20-
Those values can also be passed inside the structure `Θ` (see
21-
[`EulerAngles`](@ref)).
16+
Those values can also be passed inside the structure `Θ` (see [`EulerAngles`](@ref)).
2217
23-
The rotation sequence is defined by a `:Symbol`. The possible values are:
24-
`:XYX`, `XYZ`, `:XZX`, `:XZY`, `:YXY`, `:YXZ`, `:YZX`, `:YZY`, `:ZXY`, `:ZXZ`,
25-
`:ZYX`, and `:ZYZ`. If no value is specified, then it defaults to `:ZYX`.
18+
The rotation sequence is defined by a `:Symbol`. The possible values are: `:XYX`, `XYZ`,
19+
`:XZX`, `:XZY`, `:YXY`, `:YXZ`, `:YZX`, `:YZY`, `:ZXY`, `:ZXZ`, `:ZYX`, and `:ZYZ`. If no
20+
value is specified, it defaults to `:ZYX`.
2621
2722
# Example
2823

src/conversions/angle_to_dcm.jl

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
1-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1+
## Description #############################################################################
22
#
3-
# Description
4-
# ==============================================================================
3+
# Functions related to the conversion from Euler angles to DCM.
54
#
6-
# Functions related to the conversion from Euler angles to DCM.
7-
#
8-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
5+
############################################################################################
96

107
export angle_to_dcm
118

129
"""
13-
angle_to_dcm(θ₁::Number[, θ₂::Number[, θ₃::Number]], rot_seq::Symbol = :ZYX)
14-
angle_to_dcm(Θ::EulerAngles)
10+
angle_to_dcm(θ₁::Number[, θ₂::Number[, θ₃::Number]], rot_seq::Symbol = :ZYX) -> DCM
11+
angle_to_dcm(Θ::EulerAngles) -> DCM
1512
16-
Create a direction cosine matrix that perform a set of rotations (`θ₁`, `θ₂`,
17-
`θ₃`) about the coordinate axes specified in `rot_seq`.
13+
Create a direction cosine matrix that perform a set of rotations (`θ₁`, `θ₂`, `θ₃`) about
14+
the coordinate axes specified in `rot_seq`.
1815
19-
The input values of the origin Euler angles can also be passed inside the
20-
structure `Θ` (see [`EulerAngles`](@ref)).
16+
The input values of the origin Euler angles can also be passed inside the structure `Θ` (see
17+
[`EulerAngles`](@ref)).
2118
22-
The rotation sequence is defined by a `Symbol` specifing the rotation axes. The
23-
possible values depends on the number of rotations as follows:
19+
The rotation sequence is defined by a `Symbol` specifing the rotation axes. The possible
20+
values depends on the number of rotations as follows:
2421
2522
- **1 rotation** (`θ₁`): `:X`, `:Y`, or `:Z`.
2623
- **2 rotations** (`θ₁`, `θ₂`): `:XY`, `:XZ`, `:YX`, `:YZ`, `:ZX`, or `:ZY`.
27-
- **3 rotations** (`θ₁`, `θ₂`, `θ₃`): `:XYX`, `XYZ`, `:XZX`, `:XZY`, `:YXY`,
28-
`:YXZ`, `:YZX`, `:YZY`, `:ZXY`, `:ZXZ`, `:ZYX`, or `:ZYZ`
24+
- **3 rotations** (`θ₁`, `θ₂`, `θ₃`): `:XYX`, `XYZ`, `:XZX`, `:XZY`, `:YXY`, `:YXZ`, `:YZX`,
25+
`:YZY`, `:ZXY`, `:ZXZ`, `:ZYX`, or `:ZYZ`
2926
3027
# Remarks
3128
32-
This function assigns `dcm = A3 * A2 * A1` in which `Ai` is the DCM related with
33-
the *i*-th rotation, `i Є [1,2,3]`. If the *i*-th rotation is not specified,
34-
then `Ai = I`.
29+
This function assigns `dcm = A3 * A2 * A1` in which `Ai` is the DCM related with the _i_-th
30+
rotation, `i ∈ [1,2,3]`. If the _i_-th rotation is not specified, then `Ai = I`.
3531
3632
# Example
3733
@@ -87,11 +83,7 @@ function angle_to_dcm(θ::Number, rot_seq::Symbol)
8783
end
8884
end
8985

90-
function angle_to_dcm(
91-
θ₁::T1,
92-
θ₂::T2,
93-
rot_seq::Symbol
94-
) where {T1<:Number, T2<:Number}
86+
function angle_to_dcm(θ₁::T1, θ₂::T2, rot_seq::Symbol) where {T1<:Number, T2<:Number}
9587
T = promote_type(T1, T2)
9688

9789
# Compute the sines and cosines.

0 commit comments

Comments
 (0)