Skip to content

Commit

Permalink
update quat(::Array) to return Array{<:Quaternion}
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrodium committed Sep 16, 2022
1 parent c6a3305 commit c6bc215
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Quaternion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ quat(p, v1, v2, v3) = Quaternion(p, v1, v2, v3)
quat(p, v1, v2, v3, n) = Quaternion(p, v1, v2, v3, n)
quat(x) = Quaternion(x)
quat(s, a) = Quaternion(s, a)
function quat(A::AbstractArray{T}) where T
if !isconcretetype(T)
error("`quat` not defined on abstractly-typed arrays; please convert to a more specific type")
end
convert(AbstractArray{typeof(quat(zero(T)))}, A)
end

real(::Type{Quaternion{T}}) where {T} = T
real(q::Quaternion) = q.s
Expand Down

0 comments on commit c6bc215

Please sign in to comment.