Misc. changes

This commit is contained in:
Kiana Sheibani 2022-11-30 12:54:01 -05:00
parent 0a54f607b0
commit 524486bb58
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
5 changed files with 51 additions and 3 deletions

View file

@ -25,6 +25,7 @@ isRotation' : FieldCmp a => Matrix' n a -> Bool
isRotation' mat = isOrthonormal' mat && det mat == 1
||| Try to constuct a rotation from a matrix.
export
fromMatrix : FieldCmp a => Matrix' n a -> Maybe (Rotation n a)
fromMatrix mat = if isRotation' mat then Just (unsafeMkTrans $ matrixToH mat)
else Nothing
@ -35,6 +36,11 @@ isRotation : FieldCmp a => HMatrix' n a -> Bool
isRotation {n} mat with (viewShape mat)
_ | Shape [S n, S n] = isHMatrix mat && all (==0) (mat !!.. [EndBound last, One last])
export
fromHMatrix : FieldCmp a => HMatrix' n a -> Maybe (Rotation n a)
fromHMatrix mat = if isRotation mat then Just (unsafeMkTrans mat)
else Nothing
||| Construct a 2D rotation that rotates by the given angle (in radians).
export
rotate2D : Num a => Double -> Rotation 2 Double