Tweak gibs

This commit is contained in:
2022-06-04 11:19:14 +01:00
parent 4f4c039fec
commit 2b9ad58f6f
16 changed files with 79 additions and 33 deletions
+10
View File
@@ -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