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

Safe HaskellNone
LanguageHaskell2010

Geom2d.Point

Synopsis

Documentation

class Point p where Source

Methods

x :: p a -> a Source

y :: p a -> a Source

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

Instances

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.

Methods

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

Instances

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.