Skip to content

Commit 14bcda9

Browse files
authored
Merge pull request #27 from andreasnoack/an/07
Make package work on Julia 0.7-beta
2 parents 1217540 + acb8c24 commit 14bcda9

File tree

7 files changed

+21
-8
lines changed

7 files changed

+21
-8
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ os:
44
- osx
55
julia:
66
- 0.6
7+
- 0.7
78
- nightly
89

910
matrix:

REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
julia 0.6
2+
Compat 0.48
23
DualNumbers

src/Octonion.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function log(o::Octonion)
135135
o, a = normalizea(o)
136136
s = o.s
137137
M = abs(Octonion(imag(o)))
138-
th = atan2(M, s)
138+
th = atan(M, s)
139139
if M > 0
140140
M = th / M
141141
return Octonion(log(a),

src/Quaternion.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ struct Quaternion{T<:Real} <: Number
66
norm::Bool
77
end
88

9+
(::Type{Quaternion{T}})(x::Real) where {T} = Quaternion{T}(x, 0, 0, 0, false)
10+
(::Type{Quaternion{T}})(q::Quaternion{T}) where {T<:Real} = q
11+
(::Type{Quaternion{T}})(q::Quaternion) where {T<:Real} = Quaternion{T}(q.s, q.v1, q.v2, q.v3, q.norm)
912
Quaternion(s::Real, v1::Real, v2::Real, v3::Real, n::Bool = false) =
1013
Quaternion(promote(s, v1, v2, v3)..., n)
1114
Quaternion(x::Real) = Quaternion(x, zero(x), zero(x), zero(x), abs(x) == one(x))
@@ -94,7 +97,7 @@ end
9497

9598
angleaxis(q::Quaternion) = angle(q), axis(q)
9699

97-
angle(q::Quaternion) = 2 * atan2((q.v1^2 + q.v2^2 + q.v3^2), q.s)
100+
angle(q::Quaternion) = 2 * atan((q.v1^2 + q.v2^2 + q.v3^2), q.s)
98101

99102
function axis(q::Quaternion)
100103
q = normalize(q)
@@ -121,7 +124,7 @@ function log(q::Quaternion)
121124
q, a = normalizea(q)
122125
s = q.s
123126
M = abs_imag(q)
124-
th = atan2(M, s)
127+
th = atan(M, s)
125128
if M > 0
126129
M = th / M
127130
return Quaternion(log(a), q.v1 * M, q.v2 * M, q.v3 * M)
@@ -208,7 +211,7 @@ function qrotation(rotvec::Vector{T}) where {T <: Real}
208211
Quaternion(one(T), zero(T), zero(T), zero(T), true)
209212
end
210213

211-
function qrotation{T<:Real}(dcm::Matrix{T})
214+
function qrotation(dcm::Matrix{T}) where {T<:Real}
212215
# See https://arxiv.org/pdf/math/0701759.pdf
213216
a2 = 1 + dcm[1,1] + dcm[2,2] + dcm[3,3]
214217
b2 = 1 + dcm[1,1] - dcm[2,2] - dcm[3,3]
@@ -230,7 +233,7 @@ function qrotation{T<:Real}(dcm::Matrix{T})
230233
end
231234
end
232235

233-
function qrotation{T<:Real}(dcm::Matrix{T}, qa::Quaternion)
236+
function qrotation(dcm::Matrix{T}, qa::Quaternion) where {T<:Real}
234237
q = qrotation(dcm)
235238
abs(q-qa) < abs(q+qa) ? q : -q
236239
end

src/Quaternions.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
__precompile__()
22

33
module Quaternions
4-
importall Base
4+
5+
using Compat
6+
7+
import Base: +, -, *, /, ^
8+
import Base: abs, abs2, angle, conj, cos, exp, inv, isfinite, log, real, sin, sqrt
9+
import Base: convert, promote_rule
10+
import Compat.LinearAlgebra: norm, normalize
511

612
include("Quaternion.jl")
713
include("Octonion.jl")

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Base.Test
1+
using Compat.Test
22
using Quaternions
33

44
test_associative(x, y, z, ) = @test (x y) z x (y z)

test/test_Quaternion.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2-
import Quaternions.argq
2+
using Quaternions: argq
3+
using Compat
4+
using Compat.LinearAlgebra
35

46
# creating random examples
57
sample(QT::Type{Quaternion{T}}) where {T <: Integer} = QT(rand(-100:100, 4)..., false)

0 commit comments

Comments
 (0)