Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
KM3io.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
common
KM3io.jl
Commits
3314f318
Verified
Commit
3314f318
authored
9 months ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Add Quaternion -> Compass (and tests)
parent
3eeef859
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/root/calibration.jl
+21
-4
21 additions, 4 deletions
src/root/calibration.jl
test/math.jl
+12
-1
12 additions, 1 deletion
test/math.jl
with
33 additions
and
5 deletions
src/root/calibration.jl
+
21
−
4
View file @
3314f318
...
...
@@ -68,10 +68,10 @@ end
"""
A compass with yaw, pitch and roll.
"""
struct
Compass
yaw
::
Float64
pitch
::
Float64
roll
::
Float64
struct
Compass
{
T
}
<:
FieldVector
{
3
,
T
}
yaw
::
T
pitch
::
T
roll
::
T
end
"""
...
...
@@ -95,3 +95,20 @@ function Compass(q::Quaternion)
Compass
(
yaw
,
pitch
,
roll
)
end
Quaternion
(
c
::
Compass
)
=
Quaternion
(
c
.
yaw
,
c
.
pitch
,
c
.
roll
)
function
Quaternion
(
yaw
,
pitch
,
roll
)
cr
=
cos
(
-
roll
*
0.5
)
sr
=
sin
(
-
roll
*
0.5
)
cp
=
cos
(
pitch
*
0.5
)
sp
=
sin
(
pitch
*
0.5
)
cy
=
cos
(
-
yaw
*
0.5
)
sy
=
sin
(
-
yaw
*
0.5
)
Quaternion
(
cr
*
cp
*
cy
+
sr
*
sp
*
sy
,
sr
*
cp
*
cy
-
cr
*
sp
*
sy
,
cr
*
sp
*
cy
+
sr
*
cp
*
sy
,
cr
*
cp
*
sy
-
sr
*
sp
*
cy
)
end
This diff is collapsed.
Click to expand it.
test/math.jl
+
12
−
1
View file @
3314f318
import
KM3io
:
slerp
using
KM3io
using
Test
@testset
"slerp()"
begin
...
...
@@ -27,3 +27,14 @@ using Test
@test
[
0.70710678
,
0.0
,
0.70710678
]
≈
slerp
(
q1
,
q2
,
0.5
)
@test
[
0.45399049973954686
,
0.0
,
0.8910065241883678
]
≈
slerp
(
q1
,
q2
,
0.7
)
end
@testset
"quaternions and compasses"
begin
c
=
Compass
(
1.0
,
1.0
,
1.0
)
q
=
Quaternion
(
c
)
@test
0.7860666291368439
==
q
.
q0
@test
-
0.16751879124639693
==
q
.
qx
@test
0.5709414713577319
==
q
.
qy
@test
-
0.16751879124639693
==
q
.
qz
@test
c
≈
Compass
(
q
)
end
This diff is collapsed.
Click to expand it.
Tamas Gal
@tgal
mentioned in commit
3ee80b12
·
9 months ago
mentioned in commit
3ee80b12
mentioned in commit 3ee80b12fba115baa95ad412271efa401b700b1d
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment