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

Geom2D

Description

Basic 2 dimensional geometry functions.

Synopsis

# Documentation

module Data.Cross

data Point a Source #

Constructors

 Point FieldspointX :: !a pointY :: !a

Instances

 Source # Methodsfmap :: (a -> b) -> Point a -> Point b #(<$) :: a -> Point b -> Point a # Source # Methodsfold :: Monoid m => Point m -> m #foldMap :: Monoid m => (a -> m) -> Point a -> m #foldr :: (a -> b -> b) -> b -> Point a -> b #foldr' :: (a -> b -> b) -> b -> Point a -> b #foldl :: (b -> a -> b) -> b -> Point a -> b #foldl' :: (b -> a -> b) -> b -> Point a -> b #foldr1 :: (a -> a -> a) -> Point a -> a #foldl1 :: (a -> a -> a) -> Point a -> a #toList :: Point a -> [a] #null :: Point a -> Bool #length :: Point a -> Int #elem :: Eq a => a -> Point a -> Bool #maximum :: Ord a => Point a -> a #minimum :: Ord a => Point a -> a #sum :: Num a => Point a -> a #product :: Num a => Point a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> Point a -> f (Point b) #sequenceA :: Applicative f => Point (f a) -> f (Point a) #mapM :: Monad m => (a -> m b) -> Point a -> m (Point b) #sequence :: Monad m => Point (m a) -> m (Point a) # Unbox a => Vector Vector (Point a) Source # MethodsbasicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Point a) -> m (Vector (Point a)) #basicUnsafeThaw :: PrimMonad m => Vector (Point a) -> m (Mutable Vector (PrimState m) (Point a)) #basicLength :: Vector (Point a) -> Int #basicUnsafeSlice :: Int -> Int -> Vector (Point a) -> Vector (Point a) #basicUnsafeIndexM :: Monad m => Vector (Point a) -> Int -> m (Point a) #basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Point a) -> Vector (Point a) -> m () #elemseq :: Vector (Point a) -> Point a -> b -> b # Unbox a => MVector MVector (Point a) Source # MethodsbasicLength :: MVector s (Point a) -> Int #basicUnsafeSlice :: Int -> Int -> MVector s (Point a) -> MVector s (Point a) #basicOverlaps :: MVector s (Point a) -> MVector s (Point a) -> Bool #basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Point a)) #basicInitialize :: PrimMonad m => MVector (PrimState m) (Point a) -> m () #basicUnsafeReplicate :: PrimMonad m => Int -> Point a -> m (MVector (PrimState m) (Point a)) #basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Point a) -> Int -> m (Point a) #basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Point a) -> Int -> Point a -> m () #basicClear :: PrimMonad m => MVector (PrimState m) (Point a) -> m () #basicSet :: PrimMonad m => MVector (PrimState m) (Point a) -> Point a -> m () #basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Point a) -> MVector (PrimState m) (Point a) -> m () #basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Point a) -> MVector (PrimState m) (Point a) -> m () #basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Point a) -> Int -> m (MVector (PrimState m) (Point a)) # Eq a => Eq (Point a) Source # Methods(==) :: Point a -> Point a -> Bool #(/=) :: Point a -> Point a -> Bool # Ord a => Ord (Point a) Source # Methodscompare :: Point a -> Point a -> Ordering #(<) :: Point a -> Point a -> Bool #(<=) :: Point a -> Point a -> Bool #(>) :: Point a -> Point a -> Bool #(>=) :: Point a -> Point a -> Bool #max :: Point a -> Point a -> Point a #min :: Point a -> Point a -> Point a # Show a => Show (Point a) Source # MethodsshowsPrec :: Int -> Point a -> ShowS #show :: Point a -> String #showList :: [Point a] -> ShowS # Unbox a => Unbox (Point a) Source # Floating e => HasNormal (Point e) Source # MethodsnormalVec :: Point e -> Point e # Num e => VectorSpace (Point e) Source # Associated Typestype Scalar (Point e) :: * # Methods(*^) :: Scalar (Point e) -> Point e -> Point e # (AdditiveGroup e, Num e) => InnerSpace (Point e) Source # Methods(<.>) :: Point e -> Point e -> Scalar (Point e) # Num e => AdditiveGroup (Point e) Source # MethodszeroV :: Point e #(^+^) :: Point e -> Point e -> Point e #negateV :: Point e -> Point e #(^-^) :: Point e -> Point e -> Point e # Num a => AffineTransform (Point a) a Source # Methodstransform :: 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)) type Scalar (Point e) Source # type Scalar (Point e) = e 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  Source # Methodsfmap :: (a -> b) -> Transform a -> Transform b #(<$) :: a -> Transform b -> Transform a # Source # Methodsfold :: Monoid m => Transform m -> m #foldMap :: Monoid m => (a -> m) -> Transform a -> m #foldr :: (a -> b -> b) -> b -> Transform a -> b #foldr' :: (a -> b -> b) -> b -> Transform a -> b #foldl :: (b -> a -> b) -> b -> Transform a -> b #foldl' :: (b -> a -> b) -> b -> Transform a -> b #foldr1 :: (a -> a -> a) -> Transform a -> a #foldl1 :: (a -> a -> a) -> Transform a -> a #toList :: Transform a -> [a] #null :: Transform a -> Bool #length :: Transform a -> Int #elem :: Eq a => a -> Transform a -> Bool #maximum :: Ord a => Transform a -> a #minimum :: Ord a => Transform a -> a #sum :: Num a => Transform a -> a #product :: Num a => Transform a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> Transform a -> f (Transform b) #sequenceA :: Applicative f => Transform (f a) -> f (Transform a) #mapM :: Monad m => (a -> m b) -> Transform a -> m (Transform b) #sequence :: Monad m => Transform (m a) -> m (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 # MethodsshowsPrec :: Int -> Transform a -> ShowS #show :: Transform a -> String #showList :: [Transform a] -> ShowS # Num a => AffineTransform (Transform a) a Source # Methodstransform :: Transform a -> Transform a -> Transform a Source #

data Line a Source #

Constructors

 Line (Point a) (Point a)

Instances

 Source # Methodsfmap :: (a -> b) -> Line a -> Line b #(<$) :: a -> Line b -> Line a # Source # Methodsfold :: Monoid m => Line m -> m #foldMap :: Monoid m => (a -> m) -> Line a -> m #foldr :: (a -> b -> b) -> b -> Line a -> b #foldr' :: (a -> b -> b) -> b -> Line a -> b #foldl :: (b -> a -> b) -> b -> Line a -> b #foldl' :: (b -> a -> b) -> b -> Line a -> b #foldr1 :: (a -> a -> a) -> Line a -> a #foldl1 :: (a -> a -> a) -> Line a -> a #toList :: Line a -> [a] #null :: Line a -> Bool #length :: Line a -> Int #elem :: Eq a => a -> Line a -> Bool #maximum :: Ord a => Line a -> a #minimum :: Ord a => Line a -> a #sum :: Num a => Line a -> a #product :: Num a => Line a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> Line a -> f (Line b) #sequenceA :: Applicative f => Line (f a) -> f (Line a) #mapM :: Monad m => (a -> m b) -> Line a -> m (Line b) #sequence :: Monad m => Line (m a) -> m (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 # MethodsshowsPrec :: Int -> Line a -> ShowS #show :: Line a -> String #showList :: [Line a] -> ShowS # data Polygon a Source # Constructors  Polygon [Point a] Instances  Source # Methodsfmap :: (a -> b) -> Polygon a -> Polygon b #(<$) :: a -> Polygon b -> Polygon a # Source # Methodsfold :: Monoid m => Polygon m -> m #foldMap :: Monoid m => (a -> m) -> Polygon a -> m #foldr :: (a -> b -> b) -> b -> Polygon a -> b #foldr' :: (a -> b -> b) -> b -> Polygon a -> b #foldl :: (b -> a -> b) -> b -> Polygon a -> b #foldl' :: (b -> a -> b) -> b -> Polygon a -> b #foldr1 :: (a -> a -> a) -> Polygon a -> a #foldl1 :: (a -> a -> a) -> Polygon a -> a #toList :: Polygon a -> [a] #null :: Polygon a -> Bool #length :: Polygon a -> Int #elem :: Eq a => a -> Polygon a -> Bool #maximum :: Ord a => Polygon a -> a #minimum :: Ord a => Polygon a -> a #sum :: Num a => Polygon a -> a #product :: Num a => Polygon a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> Polygon a -> f (Polygon b) #sequenceA :: Applicative f => Polygon (f a) -> f (Polygon a) #mapM :: Monad m => (a -> m b) -> Polygon a -> m (Polygon b) #sequence :: Monad m => Polygon (m a) -> m (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 # MethodsshowsPrec :: Int -> Polygon a -> ShowS #show :: Polygon a -> String #showList :: [Polygon a] -> ShowS # Num a => AffineTransform (Polygon a) a Source # Methodstransform :: 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 #

Instances

 Num a => AffineTransform (Polygon a) a Source # Methodstransform :: Transform a -> Polygon a -> Polygon a Source # Num a => AffineTransform (Transform a) a Source # Methodstransform :: Transform a -> Transform a -> Transform a Source # Num a => AffineTransform (Point a) a Source # Methodstransform :: Transform a -> Point a -> Point a Source # Num a => AffineTransform (ClosedPath a) a Source # Methods Num a => AffineTransform (OpenPath a) a Source # Methodstransform :: Transform a -> OpenPath a -> OpenPath a Source # Num a => AffineTransform (PathJoin a) a Source # Methodstransform :: Transform a -> PathJoin a -> PathJoin a Source # Num a => AffineTransform (QuadBezier a) a Source # Methods Num a => AffineTransform (CubicBezier a) a Source # Methods (Floating a, Eq a) => AffineTransform (Pen a) a Source # Methodstransform :: Transform a -> Pen a -> Pen a Source #

(\$*) :: AffineTransform a b => Transform b -> a -> a infixr 5 Source #

Operator for applying a transformation.

inverse :: (Eq 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.

vectorMagSquare :: 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 => 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.

turnAround :: Num a => Point a -> Point a Source #

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.

idTrans :: Num a => Transform a Source #

The identity transformation.