Safe Haskell | None |
---|---|
Language | Haskell98 |
Geom2D
Description
Basic 2 dimensional geometry functions.
- module Data.VectorSpace
- module Data.Cross
- data Point a = Point {}
- type DPoint = Point Double
- data Transform a = Transform {}
- data Line a = Line (Point a) (Point a)
- data Polygon a = Polygon [Point a]
- class AffineTransform a b | a -> b where
- ($*) :: AffineTransform a b => Transform b -> a -> a
- inverse :: (Eq a, Fractional a) => Transform a -> Maybe (Transform a)
- lineEquation :: Floating t => Line t -> (t, t, t)
- lineDistance :: Floating a => Line a -> Point a -> a
- closestPoint :: Fractional a => Line a -> Point a -> Point a
- lineIntersect :: (Ord a, Floating a) => Line a -> Line a -> a -> Maybe (Point a)
- vectorMag :: Floating a => Point a -> a
- vectorMagSquare :: Floating a => Point a -> a
- vectorAngle :: RealFloat a => Point a -> a
- dirVector :: Floating a => a -> Point a
- normVector :: Floating a => Point a -> Point a
- (^.^) :: Num a => Point a -> Point a -> a
- vectorCross :: Num a => Point a -> Point a -> a
- vectorDistance :: Floating a => Point a -> Point a -> a
- interpolateVector :: Num a => Point a -> Point a -> a -> Point a
- rotateScaleVec :: Num a => Point a -> Transform a
- flipVector :: Num a => Point a -> Point a
- turnAround :: Num a => Point a -> Point a
- rotateVec :: Floating a => Point a -> Transform a
- rotate :: Floating s => s -> Transform s
- rotate90L :: Floating s => Transform s
- rotate90R :: Floating s => Transform s
- translate :: Num a => Point a -> Transform a
- idTrans :: Num a => Transform a
Documentation
module Data.VectorSpace
module Data.Cross
Instances
Functor Point # | |
Foldable Point # | |
Traversable Point # | |
Unbox a => Vector Vector (Point a) # | |
Unbox a => MVector MVector (Point a) # | |
Eq a => Eq (Point a) # | |
Ord a => Ord (Point a) # | |
Show a => Show (Point a) # | |
Unbox a => Unbox (Point a) # | |
Floating e => HasNormal (Point e) # | |
Num e => VectorSpace (Point e) # | |
(AdditiveGroup e, Num e) => InnerSpace (Point e) # | |
Num e => AdditiveGroup (Point e) # | |
Num a => AffineTransform (Point a) a # | |
data MVector s (Point a) # | |
data Vector (Point a) # | |
type Scalar (Point e) # | |
A transformation (x, y) -> (ax + by + c, dx + ey + d)
Constructors
Transform | |
class AffineTransform a b | a -> b where #
Minimal complete definition
Instances
Num a => AffineTransform (Polygon a) a # | |
Num a => AffineTransform (Transform a) a # | |
Num a => AffineTransform (Point a) a # | |
Num a => AffineTransform (ClosedPath a) a # | |
Num a => AffineTransform (OpenPath a) a # | |
Num a => AffineTransform (PathJoin a) a # | |
Num a => AffineTransform (QuadBezier a) a # | |
Num a => AffineTransform (CubicBezier a) a # | |
(Floating a, Eq a) => AffineTransform (Pen a) a # | |
($*) :: AffineTransform a b => Transform b -> a -> a infixr 5 #
Operator for applying a transformation.
inverse :: (Eq a, Fractional a) => Transform a -> Maybe (Transform a) #
Calculate the inverse of a transformation.
lineEquation :: Floating t => Line t -> (t, t, t) #
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 #
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 #
Return the point on the line closest to the given point.
lineIntersect :: (Ord a, Floating a) => Line a -> Line a -> a -> Maybe (Point a) #
Calculate the intersection of two lines. If the determinant is less than tolerance (parallel or coincident lines), return Nothing.
vectorMagSquare :: Floating a => Point a -> a #
The lenght of the vector.
normVector :: Floating a => Point a -> Point a #
The unit vector with the same direction.
vectorCross :: Num a => Point a -> Point a -> a #
Cross product of two vectors.
vectorDistance :: Floating a => Point a -> Point a -> a #
Distance between two vectors.
rotateScaleVec :: Num a => Point a -> Transform a #
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 #
reflect the vector over the X-axis.
turnAround :: Num a => Point a -> Point a #
rotateVec :: Floating a => Point a -> Transform a #
Create a transform that rotates by the angle of the given vector with the x-axis
rotate :: Floating s => s -> Transform s #
Create a transform that rotates by the given angle (radians).