mirror of
https://gitlab.com/MisterBiggs/astro-helper.git
synced 2025-08-02 19:31:23 +00:00
added quaternion from ypr
This commit is contained in:
@@ -8,7 +8,8 @@ struct Quaternion
|
||||
Quaternion(q) = Quaternion(q[1], q[2], q[3], q[4])
|
||||
Quaternion() = new(0, 0, 0, 1)
|
||||
|
||||
# Quaternion(ē, ϕ) = Quaternion(vcat(if sum(ē) == 0 ? [0 0 0] : ē / norm(ē) * sin(ϕ / 2),cos(ϕ / 2)))
|
||||
Quaternion(yaw, pitch, roll) = Quaternion([0 0 sin(yaw / 2) cos(yaw / 2)]) * Quaternion([0 sin(pitch / 2) 0 cos(pitch / 2)]) * Quaternion([sin(roll / 2) 0 0 cos(roll / 2)])
|
||||
|
||||
function Quaternion(ē, ϕ)
|
||||
if sum(ē) == 0
|
||||
return Quaternion([0 0 0 cos(ϕ / 2)])
|
||||
@@ -40,6 +41,6 @@ Base.isapprox(a::Quaternion,b::Quaternion) = isapprox(collect(a), collect(b))
|
||||
|
||||
LinearAlgebra.norm(q::Quaternion) = norm(collect(q))
|
||||
LinearAlgebra.normalize(q::Quaternion) = collect(q) / norm(q)
|
||||
# q = Quaternion([1,-2,2], -2 * pi / 3) * Quaternion([0,0,0,1])
|
||||
|
||||
# println(q[3])
|
||||
|
||||
export Quaternion
|
||||
|
Reference in New Issue
Block a user