Safe Haskell | None |
---|---|

Language | Haskell98 |

Basic 2 dimensional geometry functions.

- data Point a = Point {}
- type DPoint = Point Double
- data Transform a = Transform {}
- data Line a = Line (Point a) (Point a)
- data Polygon a = Polygon [Point a]
- class AffineTransform a b | a -> b where
- ($*) :: AffineTransform a b => Transform b -> a -> a
- inverse :: (Eq a, Num a, Fractional a) => Transform a -> Maybe (Transform a)
- lineEquation :: Floating t => Line t -> (t, t, t)
- lineDistance :: Floating a => Line a -> Point a -> a
- closestPoint :: Fractional a => Line a -> Point a -> Point a
- vectorMag :: Floating a => Point a -> a
- vectorAngle :: RealFloat a => Point a -> a
- dirVector :: Floating a => a -> Point a
- normVector :: Floating a => Point a -> Point a
- (*^) :: Num a => a -> Point a -> Point a
- (^/) :: Fractional a => Point a -> a -> Point a
- (^*) :: Num a => Point a -> a -> Point a
- (^+^) :: Num a => Point a -> Point a -> Point a
- (^-^) :: Num a => Point a -> Point a -> Point a
- (^.^) :: Num a => Point a -> Point a -> a
- vectorCross :: Num a => Point a -> Point a -> a
- vectorDistance :: Floating a => Point a -> Point a -> a
- interpolateVector :: Num a => Point a -> Point a -> a -> Point a
- rotateScaleVec :: Num a => Point a -> Transform a
- flipVector :: Num a => Point a -> Point a
- rotateVec :: Floating a => Point a -> Transform a
- rotate :: Floating s => s -> Transform s
- rotate90L :: Floating s => Transform s
- rotate90R :: Floating s => Transform s
- translate :: Num a => Point a -> Transform a

# Documentation

A transformation (x, y) -> (ax + by + c, dx + ey + d)

class AffineTransform a b | a -> b where Source

Num a => AffineTransform (Polygon a) a | |

Num a => AffineTransform (Transform a) a | |

Num a => AffineTransform (Point a) a | |

Num a => AffineTransform (CubicBezier a) a |

($*) :: AffineTransform a b => Transform b -> a -> a infixr 5 Source

Operator for applying a transformation.

inverse :: (Eq a, Num a, Fractional a) => Transform a -> Maybe (Transform a) Source

Calculate the inverse of a transformation.

lineEquation :: Floating t => Line t -> (t, t, t) Source

Return the parameters (a, b, c) for the normalised equation
of the line: `a*x + b*y + c = 0`

.

lineDistance :: Floating a => Line a -> Point a -> a Source

Return the signed distance from a point to the line. If the distance is negative, the point lies to the right of the line

closestPoint :: Fractional a => Line a -> Point a -> Point a Source

Return the point on the line closest to the given point.

normVector :: Floating a => Point a -> Point a Source

The unit vector with the same direction.

(^/) :: Fractional a => Point a -> a -> Point a infixl 7 Source

Scale vector by reciprocal of constant.

(^*) :: Num a => Point a -> a -> Point a infixl 7 Source

Scale vector by constant, with the arguments swapped.

vectorCross :: Num a => Point a -> Point a -> a Source

Cross product of two vectors.

vectorDistance :: Floating a => Point a -> Point a -> a Source

Distance between two vectors.

interpolateVector :: Num a => Point a -> Point a -> a -> Point a Source

Interpolate between two vectors.

rotateScaleVec :: Num a => Point a -> Transform a Source

Create a transform that rotates by the angle of the given vector and multiplies with the magnitude of the vector.

flipVector :: Num a => Point a -> Point a Source

reflect the vector over the X-axis.

rotateVec :: Floating a => Point a -> Transform a Source

Create a transform that rotates by the angle of the given vector with the x-axis