Safe Haskell | Safe-Inferred |
---|
Simple 3-vectors and matrices built atop tuples.
- type Vec3 = (Double, Double, Double)
- type Matrix = (Vec3, Vec3, Vec3)
- type Point = Vec3
- origin :: Point
- (<+>) :: Vec3 -> Vec3 -> Vec3
- (<->) :: Vec3 -> Vec3 -> Vec3
- (><) :: Vec3 -> Vec3 -> Vec3
- (.^) :: Vec3 -> Double -> Vec3
- (.*) :: Vec3 -> Vec3 -> Double
- norm :: Vec3 -> Double
- normalize :: Vec3 -> Vec3
- invert :: Vec3 -> Vec3
- distance :: Point -> Point -> Double
- moveBy :: Point -> Vec3 -> Double -> Point
- mxv :: Matrix -> Vec3 -> Vec3
- vxv :: Vec3 -> Vec3 -> Matrix
- dotM :: Vec3 -> Vec3 -> Matrix -> Double
- diag :: Double -> Matrix
- addM :: Matrix -> Matrix -> Matrix
- buildCartesian :: Double -> Double -> (Vec3, Vec3, Vec3)
Documentation
Vector operations
Move point by velocity vector for given time and return new position.
Matrix operations
vxv :: Vec3 -> Vec3 -> MatrixSource
Transpose vector and multiply it by another vector, producing a matrix.
dotM :: Vec3 -> Vec3 -> Matrix -> DoubleSource
Generic vector dot product.
Multiply transpose of first vector by given matrix, then multiply the result by second vector.
addM :: Matrix -> Matrix -> MatrixSource
Add two matrices.
We could add Applicative instance for Matrix and lift (+) to it.