module Quaternion
    ( rotateToZ
    )
    where
import Geometry.Data
import Geometry.Vector3D
import qualified Linear.Quaternion as Q

-- apply a rotation as if the z axis moves to the new point.
rotateToZ :: Point3 -> Point3 -> Point3
rotateToZ z1
    | cprod == V3 0 0 0 = id
    | otherwise = Q.rotate $ Q.axisAngle cprod (angleVV3 z1 (V3 0 0 1))
  where
    cprod = crossProd z1 (V3 0 0 1)
