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

Geom2D

Description

Basic 2 dimensional geometry functions.

Synopsis

# Documentation

data Point a Source

Constructors

 Point FieldspointX :: !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 FieldsxformA :: !a xformB :: !a xformC :: !a xformD :: !a xformE :: !a xformF :: !a

Instances

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

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

Instances

 Num a => AffineTransform (Polygon a) a Num a => AffineTransform (Transform a) a Num a => AffineTransform (Point a) a Num a => AffineTransform (CubicBezier a) a

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

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

Rotate vector 90 degrees left.

Rotate vector 90 degrees right.

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

Create a transform that translates by the given vector.