cubicbezier-0.4.0.1: 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

pointX :: !a
 
pointY :: !a
 

Instances

Functor Point 
Unbox a => Vector Vector (Point a) 
Unbox a => MVector MVector (Point a) 
Eq a => Eq (Point a) 
Show a => Show (Point a) 
Unbox a => Unbox (Point a) 
Num a => AffineTransform (Point a) a 
data MVector s (Point a) = MV_Point (MVector s (a, a)) 
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

xformA :: !a
 
xformB :: !a
 
xformC :: !a
 
xformD :: !a
 
xformE :: !a
 
xformF :: !a
 

Instances

data Line a Source

Constructors

Line (Point a) (Point a) 

Instances

Functor Line 
Eq a => Eq (Line a) 
Show a => Show (Line a) 

data Polygon a Source

Constructors

Polygon [Point a] 

Instances

Functor Polygon 
Eq a => Eq (Polygon a) 
Show a => Show (Polygon a) 
Num a => AffineTransform (Polygon a) a 

class AffineTransform a b | a -> b where Source

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.

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.