Rename rotation constructors

This commit is contained in:
Kiana Sheibani 2022-10-21 10:03:43 -04:00
parent 342cff97dd
commit 1ad4c1f13c
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
13 changed files with 108 additions and 94 deletions

View file

@ -8,6 +8,7 @@ import Data.NumIdr.Matrix
import Data.NumIdr.Homogeneous
import Data.NumIdr.Transform.Point
import Data.NumIdr.Transform.Transform
import Data.NumIdr.Transform.Orthonormal
%default total
@ -17,6 +18,27 @@ Rotation : Nat -> Type -> Type
Rotation = Transform TRotation
-- HACK: Replace with more efficient method
export
isRotation' : Matrix' n a -> Bool
isRotation' mat =
isRotation' : FieldCmp a => Matrix' n a -> Bool
isRotation' mat = isOrthonormal mat && det mat == 1
fromMatrix : FieldCmp a => Matrix' n a -> Maybe (Rotation n a)
fromMatrix mat = if isRotation' mat then Just (unsafeMkTrans $ matrixToH mat)
else Nothing
export
rotate2D : Num a => Double -> Rotation 2 Double
rotate2D = unsafeMkTrans . rotate2DH
export
rotate3DX : Num a => Double -> Rotation 3 Double
rotate3DX = unsafeMkTrans . rotate3DXH
export
rotate3DY : Num a => Double -> Rotation 3 Double
rotate3DY = unsafeMkTrans . rotate3DYH
export
rotate3DZ : Num a => Double -> Rotation 3 Double
rotate3DZ = unsafeMkTrans . rotate3DZH