Cartesian-0.1.0.1: Coordinate systems

Copyright(C) 2015 Jonatan H Sundqvist
LicenseMIT-style (see the file LICENSE)
MaintainerJonatan H Sundqvist <jonatanhsundqvist@gmail.com>
Stabilityprovisional
PortabilityPortable
Safe HaskellSafe
LanguageHaskell2010

Cartesian.Space

Description

Vector and coordinate system utilities.

Synopsis

Documentation

data Vector num Source

Constructors

Vector num num num 

Instances

(Floating a, Eq a) => Num (Vector a) Source 

data Line num Source

Constructors

Line (Vector num) (Vector num) 

vector :: Num a => a -> a -> a -> Vector a Source

Why the hell did I write this useless function?

dotwise :: (a -> b -> c) -> Vector a -> Vector b -> Vector c Source

Performs component-wise operations

dot :: Floating a => Vector a -> Vector a -> a Source

Dot product of two vectors

euclidean :: Floating a => Vector a -> Vector a -> a Source

Euclidean distance between two points

magnitude :: (Floating a, Eq a) => Vector a -> a Source

mag :: (Floating a, Eq a) => Vector a -> a Source

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.) (?)

intersects :: Num a => Line a -> Line a -> Bool Source

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 (?)