Cartesian-0.2.0.0: Coordinate systems

LicenseMIT
MaintainerJonatan H Sundqvist
Stabilityexperimental|stable
PortabilityPOSIX (not sure)
Safe HaskellNone
LanguageHaskell2010

Cartesian.Plane

Description

 

Synopsis

Documentation

data Vector num Source

TODO: Rename (?)

Constructors

Vector num num 

Instances

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

abs v * signum v == v

Show num => Show (Vector num) Source 

data Line num Source

Constructors

Line (Vector num) (Vector num) 

type Polygon num = [Vector num] Source

TODO: Rename (eg. Shape) (?)

data Linear num Source

Constructors

Linear 

Fields

intercept :: num
 
slope :: num
 

inside :: Num n => Polygon n -> Vector n -> Bool Source

type Domain

Determines if a point lies within a polygon using the odd-even method.

TODO: Use epsilon (?) TODO: How to treat points that lie on an edge

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

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

Angle (in radians) between the positive X-axis and the vector

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

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

Vector -> (magnitude, argument)

intersect :: RealFrac n => Line n -> Line n -> Maybe (Vector n) Source

Yields the point at which two finite lines intersect. The lines are defined inclusively by their endpoints. The result is wrapped in a Maybe value to account for non-intersecting lines.

TODO: Move equation solving to separate function (two linear functions) TODO: Simplify logic by considering f(x) = y for vertical lines (?) TODO: Return Either instead of Maybe (eg. Left "parallel") (?)

TODO: Math notes, MathJax or LaTex TODO: Intersect for curves (functions) and single points (?) TODO: Polymorphic, typeclass (lines, shapes, ranges, etc.) (?)

intersects :: RealFrac r => Line r -> Line r -> Bool Source

inside :: (Num n, Ord n) => Triangle n -> Point n -> Bool inside _ _ = False

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). Fails for vertical and horizontal lines.

TODO: Use Maybe (?) TODO: Rename (eg. toLinear, function) (?)

solve :: (Fractional n, Eq n) => Linear n -> Linear n -> Maybe n Source

Solves a linear equation for x (f(x) = g(x)) TODO: Use Epsilon (?)