Skip to content

Commit

Permalink
add docstring of slerp
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrodium committed Oct 17, 2022
1 parent c0deff1 commit 56224b4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Quaternion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,29 @@ function rotationmatrix_normalized(q::Quaternion)
xz - sy yz + sx 1 - (xx + yy)]
end

"""
slerp(qa::Quaternion, qb::Quaternion, t::Real)
Spherical linear interpolation (Slerp) between the inputs `qa` and `qb`.
Since the input is normalized inside the function, the absolute value of the return value will be 1.
# Examples
```jldoctest
julia> using Quaternions
julia> qa = Quaternion(1,0,0,0)
Quaternion{Int64}(1, 0, 0, 0, false)
julia> qb = Quaternion(0,1,0,0)
Quaternion{Int64}(0, 1, 0, 0, false)
julia> slerp(qa, qb, 0.6)
QuaternionF64(0.5877852522924731, 0.8090169943749475, 0.0, 0.0, true)
julia> ans ≈ Quaternion(cospi(0.3), sinpi(0.3), 0, 0)
true
```
"""
@inline function slerp(qa0::Quaternion{T}, qb0::Quaternion{T}, t::T) where T<:Real
# http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
iszero(qa0) && throw(DomainError(qa0, "The input quaternion must be non-zero."))
Expand Down

0 comments on commit 56224b4

Please sign in to comment.