Copyright | (C) 2015 Jonatan H Sundqvist |
---|---|
License | MIT-style (see the file LICENSE) |
Maintainer | Jonatan H Sundqvist <jonatanhsundqvist@gmail.com> |
Stability | provisional |
Portability | Portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Cartesian.Space
Description
Vector and coordinate system utilities.
- data Vector num = Vector num num num
- data Line num = Line (Vector num) (Vector num)
- vector :: Num a => a -> a -> a -> Vector a
- dotwise :: (a -> b -> c) -> Vector a -> Vector b -> Vector c
- dot :: Floating a => Vector a -> Vector a -> a
- euclidean :: Floating a => Vector a -> Vector a -> a
- magnitude :: (Floating a, Eq a) => Vector a -> a
- mag :: (Floating a, Eq a) => Vector a -> a
- intersect :: Num a => Line a -> Line a -> Maybe (Vector a)
- intersects :: Num a => Line a -> Line a -> Bool
- overlap :: Real a => (a, a) -> (a, a) -> Maybe (a, a)
- coefficients :: (Fractional a, Eq a) => Line a -> Maybe (a, a)
Documentation
Constructors
Vector num num num |
dotwise :: (a -> b -> c) -> Vector a -> Vector b -> Vector c Source
Performs component-wise operations
intersect :: Num a => Line a -> Line a -> Maybe (Vector a) Source
Angle (in radians) between the positive X-axis and the vector argument :: (Floating a, Eq a) => Vector a -> a argument (Vector 0 0 0) = 0 argument (Vector x y z) = atan $ y/x
Vector -> (magnitude, argument) polar :: (Floating a, Eq a) => Vector a -> (a, a) polar v@(Vector x y) = (magnitude v, argument v)
Intersect TODO: Math notes, MathJax or LaTex TODO: Intersect for curves (functions) and single points (?) TODO: Polymorphic, typeclass (lines, shapes, ranges, etc.) (?)
overlap :: Real a => (a, a) -> (a, a) -> Maybe (a, a) Source
Yields the overlap of two closed intervals (n ∈ R) TODO: Normalise intervals (eg. (12, 5) -> (5, 12))
coefficients :: (Fractional a, Eq a) => Line a -> Maybe (a, a) Source
TODO: Intersect Rectangles
Coefficients for the linear function of a Line (slope, intercept). The Z-component is ignored. Fails for vertical and horizontal lines.
TODO: Use Maybe (?)