linear 1.8 → 1.8.1
raw patch · 3 files changed
+10/−5 lines, 3 files
Files
- CHANGELOG.markdown +4/−0
- linear.cabal +1/−1
- src/Linear/Quaternion.hs +5/−4
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+1.8.1+-----+* Bugfixed `slerp`+ 1.8 --- * Added missing `Unbox` instances for working with unboxed vectors of `linear` data types.
linear.cabal view
@@ -1,6 +1,6 @@ name: linear category: Math, Algebra-version: 1.8+version: 1.8.1 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE
src/Linear/Quaternion.hs view
@@ -469,14 +469,15 @@ {-# INLINE atanhq #-} -- | Spherical linear interpolation between two quaternions.+ slerp :: RealFloat a => Quaternion a -> Quaternion a -> a -> Quaternion a slerp q p t | 1.0 - cosphi < 1e-8 = q- | phi <- acos cosphi, r <- recip (sin phi)- = (sin ((1-t)*phi)*r *^ q ^+^ f (sin (t*phi)*r) *^ p) ^/ sin phi+ | otherwise = ((sin ((1-t)*phi) *^ q) + (sin (t*phi)) *^ (f p)) ^/ (sin phi) where- dqp = dot q p- (cosphi, f) = if dqp < 0 then (-dqp, negate) else (dqp, id)+ dqp = dot q p+ (cosphi, f) = if dqp < 0 then (-dqp, negate) else (dqp, id)+ phi = acos cosphi {-# SPECIALIZE slerp :: Quaternion Float -> Quaternion Float -> Float -> Quaternion Float #-} {-# SPECIALIZE slerp :: Quaternion Double -> Quaternion Double -> Double -> Quaternion Double #-}