Module
Linear.Matrix
- Package
- purescript-linear
- Repository
- afcondon/purescript-linear
Matrix types and operations.
Matrices are represented as vectors of row vectors, following Haskell's linear. This module provides type aliases and operations for common matrix sizes.
#identity22 Source
identity22 :: forall a. Semiring a => M22 a2x2 identity matrix.
#identity33 Source
identity33 :: forall a. Semiring a => M33 a3x3 identity matrix.
#identity44 Source
identity44 :: forall a. Semiring a => M44 a4x4 identity matrix.
#fromQuaternion Source
fromQuaternion :: Quaternion Number -> M33 NumberConvert a unit quaternion to a 3x3 rotation matrix.
fromQuaternion (Quaternion 1.0 (V3 0.0 0.0 0.0)) = identity33
#mkTransformation Source
mkTransformation :: Quaternion Number -> V3 Number -> M44 NumberBuild a 4x4 transformation matrix from a quaternion rotation and translation.
The resulting matrix applies rotation first, then translation.
mkTransformation identity (V3 1.0 2.0 3.0) -- pure translation
mkTransformation rotation (V3 0.0 0.0 0.0) -- pure rotation
#transpose22 Source
transpose22 :: forall a. M22 a -> M22 aTranspose a 2x2 matrix.
#transpose33 Source
transpose33 :: forall a. M33 a -> M33 aTranspose a 3x3 matrix.
#transpose44 Source
transpose44 :: forall a. M44 a -> M44 aTranspose a 4x4 matrix.
#diagonal33 Source
diagonal33 :: forall a. M33 a -> V3 aExtract the diagonal of a 3x3 matrix.