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

Language | Haskell98 |

Basic 2 dimensional geometry functions.

- module Data.VectorSpace
- module Data.Cross
- 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, 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
- lineIntersect :: (Ord a, Floating a) => Line a -> Line a -> a -> Maybe (Point a)
- vectorMag :: Floating a => Point a -> a
- vectorMagSquare :: 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 => 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
- turnAround :: 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
- idTrans :: Num a => Transform a

# Documentation

module Data.VectorSpace

module Data.Cross

Functor Point Source # | |

Foldable Point Source # | |

Traversable Point Source # | |

Unbox a => Vector Vector (Point a) Source # | |

Unbox a => MVector MVector (Point a) Source # | |

Eq a => Eq (Point a) Source # | |

Ord a => Ord (Point a) Source # | |

Show a => Show (Point a) Source # | |

Unbox a => Unbox (Point a) Source # | |

Floating e => HasNormal (Point e) Source # | |

Num e => VectorSpace (Point e) Source # | |

(AdditiveGroup e, Num e) => InnerSpace (Point e) Source # | |

Num e => AdditiveGroup (Point e) Source # | |

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

data MVector s (Point a) Source # | |

data Vector (Point a) Source # | |

type Scalar (Point e) Source # | |

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

class AffineTransform a b | a -> b where Source #

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

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

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

Num a => AffineTransform (ClosedPath a) a Source # | |

Num a => AffineTransform (OpenPath a) a Source # | |

Num a => AffineTransform (PathJoin a) a Source # | |

Num a => AffineTransform (QuadBezier a) a Source # | |

Num a => AffineTransform (CubicBezier a) a Source # | |

(Floating a, Eq a) => AffineTransform (Pen a) a Source # | |

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

Operator for applying a transformation.

inverse :: (Eq 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.

lineIntersect :: (Ord a, Floating a) => Line a -> Line a -> a -> Maybe (Point a) Source #

Calculate the intersection of two lines. If the determinant is less than tolerance (parallel or coincident lines), return Nothing.

vectorMagSquare :: Floating a => Point a -> a Source #

The lenght of the vector.

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.

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

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

rotate :: Floating s => s -> Transform s Source #

Create a transform that rotates by the given angle (radians).