Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*.jl.mem
docs/build/
docs/site/
Manifest.toml
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
julia = "1"
Crayons = "4.0"
StaticArrays = "1"
julia = "1"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
3 changes: 2 additions & 1 deletion src/ReferenceFrameRotations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ using StaticArrays
export I

################################################################################
# Types
# Types & Conversions
################################################################################

include("types.jl")
include("conversions.jl")

################################################################################
# Constants
Expand Down
21 changes: 21 additions & 0 deletions src/conversions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Description
# ==============================================================================
#
# Conversion methods between different rotation types.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# Base.convert is already exported

################################################################################
# Conversion Methods
################################################################################

# TODO: deprecate angle_to_dcm, quat_to_dcm, ...
# TODO: move all the implementations over here

Base.convert(::Type{<:DCM}, a::EulerAngles) = angle_to_dcm(a)
Base.convert(::Type{<:DCM}, a::Quaternion) = quat_to_dcm(a)
Base.convert(::Type{<:DCM}, a::EulerAngleAxis) = angleaxis_to_dcm(a)
29 changes: 29 additions & 0 deletions test/conversions.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Desription
# ==============================================================================
#
# Tests related to conversion methods.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# File: ./src/conversions.jl
# =========================================

# Functions: Base.convert
# -------------------------

@testset "Conversion Methods" begin
T = Float64

for rot_seq in valid_rot_seqs
# Sample Euler angles.
ea = EulerAngles(_rand_ang(T), _rand_ang(T), _rand_ang(T), rot_seq)

# Convert to DCM.
D = convert(DCM, ea)
@test D isa SArray
@test eltype(D) === T
@test size(D) == (3, 3)
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ end
println("")

@time @addverbose @testset "Conversions" begin
include("conversions.jl")
include("./conversions/angle_to_angle.jl")
include("./conversions/angle_to_angleaxis.jl")
include("./conversions/angle_to_dcm.jl")
Expand Down