geom2d-0.2.2: package for geometry in euklidean 2d space

Safe HaskellNone




class Point p where Source


x :: p a -> a Source

y :: p a -> a Source

fromCoords :: a -> a -> p a Source

data Point' a Source

This data type modells the the characteristics of vectors in 2 dimensional space. You should construct it via fromCoords.

type Triangle p = (p, p, p) Source

A triangle is simply a tuple of three points.

class Scale p where Source

This type class modells data that can be scaled by a factor.


scale :: Num a => a -> p a -> p a Source

normalize :: (Scale p, Point p, Eq a, Floating a) => p a -> Maybe (p a) Source

Normalizes a scaleable point to length 1.

scaleTo :: (Scale p, Point p, Eq a, Floating a) => a -> p a -> Maybe (p a) Source

magnitude :: (Point p, Floating a, Num a) => p a -> a Source

Return the magnitude of a vector.

dot :: (Num a, Point p) => p a -> p a -> a infixl 7 Source

This function defines the dot product of two vectors.

cross :: (Num a, Point p) => p a -> p a -> a infixl 7 Source

This function defined the cross product of two vectors.

triArea :: (Point p, Num (p a), Fractional a) => Triangle (p a) -> a Source

Calculate the area of a triangle.

pointInTriangle :: (Eq (p a), Num (p a), Fractional a, Point p, Ord a) => Triangle (p a) -> p a -> Bool Source

Determin whether a point is in a triangle. A point being on the edge is considered inside the triangle.