Tweak gibs
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
module Quaternion
|
||||
( rotateToZ
|
||||
, vToQuat
|
||||
, module Linear.Quaternion
|
||||
) where
|
||||
import Geometry.Data
|
||||
import Geometry.Vector3D
|
||||
import qualified Linear.Quaternion as Q
|
||||
import Linear.Quaternion
|
||||
|
||||
-- apply a rotation as if the z axis moves to the new point.
|
||||
rotateToZ :: Point3 -> Point3 -> Point3
|
||||
@@ -12,3 +15,10 @@ rotateToZ z1
|
||||
| otherwise = Q.rotate $ Q.axisAngle cprod (angleVV3 z1 (V3 0 0 1))
|
||||
where
|
||||
cprod = crossProd z1 (V3 0 0 1)
|
||||
|
||||
vToQuat :: Point3 -> Point3 -> Q.Quaternion Float
|
||||
vToQuat a b
|
||||
| cprod == V3 0 0 0 = Q.axisAngle (V3 0 0 1) 0
|
||||
| otherwise = Q.axisAngle cprod (angleVV3 a b)
|
||||
where
|
||||
cprod = crossProd a b
|
||||
|
||||
Reference in New Issue
Block a user