cubicbezier-0.5.0.0: Efficient manipulating of 2D cubic bezier curves.

Safe HaskellNone
LanguageHaskell98

Geom2D

Description

Basic 2 dimensional geometry functions.

Synopsis

Documentation

data Point a Source #

Constructors

Point 

Fields

Instances

Functor Point Source # 

Methods

fmap :: (a -> b) -> Point a -> Point b #

(<$) :: a -> Point b -> Point a #

Unbox a => Vector Vector (Point a) Source # 
Unbox a => MVector MVector (Point a) Source # 
Eq a => Eq (Point a) Source # 

Methods

(==) :: Point a -> Point a -> Bool #

(/=) :: Point a -> Point a -> Bool #

Show a => Show (Point a) Source # 

Methods

showsPrec :: Int -> Point a -> ShowS #

show :: Point a -> String #

showList :: [Point a] -> ShowS #

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

Methods

transform :: Transform a -> Point a -> Point a Source #

data MVector s (Point a) Source # 
data MVector s (Point a) = MV_Point (MVector s (a, a))
data Vector (Point a) Source # 
data Vector (Point a) = V_Point (Vector (a, a))

data Transform a Source #

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

Constructors

Transform 

Fields

Instances

Functor Transform Source # 

Methods

fmap :: (a -> b) -> Transform a -> Transform b #

(<$) :: a -> Transform b -> Transform a #

Eq a => Eq (Transform a) Source # 

Methods

(==) :: Transform a -> Transform a -> Bool #

(/=) :: Transform a -> Transform a -> Bool #

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

data Line a Source #

Constructors

Line (Point a) (Point a) 

Instances

Functor Line Source # 

Methods

fmap :: (a -> b) -> Line a -> Line b #

(<$) :: a -> Line b -> Line a #

Eq a => Eq (Line a) Source # 

Methods

(==) :: Line a -> Line a -> Bool #

(/=) :: Line a -> Line a -> Bool #

Show a => Show (Line a) Source # 

Methods

showsPrec :: Int -> Line a -> ShowS #

show :: Line a -> String #

showList :: [Line a] -> ShowS #

data Polygon a Source #

Constructors

Polygon [Point a] 

Instances

Functor Polygon Source # 

Methods

fmap :: (a -> b) -> Polygon a -> Polygon b #

(<$) :: a -> Polygon b -> Polygon a #

Eq a => Eq (Polygon a) Source # 

Methods

(==) :: Polygon a -> Polygon a -> Bool #

(/=) :: Polygon a -> Polygon a -> Bool #

Show a => Show (Polygon a) Source # 

Methods

showsPrec :: Int -> Polygon a -> ShowS #

show :: Polygon a -> String #

showList :: [Polygon a] -> ShowS #

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

Methods

transform :: Transform a -> Polygon a -> Polygon a Source #

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

Minimal complete definition

transform

Methods

transform :: Transform b -> a -> a Source #

($*) :: 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.

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.

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

The lenght of the vector.

vectorAngle :: RealFloat a => Point a -> a Source #

The angle of the vector, in the range (-pi, pi].

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

The unitvector with the given angle.

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

The unit vector with the same direction.

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

Scale vector by constant.

(^/) :: 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.

(^+^) :: Num a => Point a -> Point a -> Point a infixl 6 Source #

Add two vectors.

(^-^) :: Num a => Point a -> Point a -> Point a infixl 6 Source #

Subtract two vectors.

(^.^) :: Num a => Point a -> Point a -> a Source #

Dot product of two vectors.

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

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

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

rotate90L :: Floating s => Transform s Source #

Rotate vector 90 degrees left.

rotate90R :: Floating s => Transform s Source #

Rotate vector 90 degrees right.

translate :: Num a => Point a -> Transform a Source #

Create a transform that translates by the given vector.

idTrans :: Num a => Transform a Source #

The identity transformation.