reanimate-1.1.5.0: Animation library based on SVGs.
CopyrightWritten by David Himmelstrup
LicenseUnlicense
Maintainerlemmih@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Reanimate.Math.Common

Description

Low-level primitives related to computational geometry.

Synopsis

Ring

newtype Ring a Source #

Circular collection of pairs.

Constructors

Ring (Vector (V2 a)) 

ringSize :: Ring a -> Int Source #

Number of elements in the ring.

ringAccess :: Ring a -> Int -> V2 a Source #

Safe method for accessing elements in the ring.

ringClamp :: Ring a -> Int -> Int Source #

Clamp index to within the usable range for the ring.

ringUnpack :: Ring a -> Vector (V2 a) Source #

Convert ring to a vector.

ringPack :: Vector (V2 a) -> Ring a Source #

Convert vector to a ring.

ringMap :: (V2 a -> V2 b) -> Ring a -> Ring b Source #

Map each element of a ring.

ringRayIntersect :: Ring Rational -> (Int, Int) -> (Int, Int) -> Maybe (V2 Rational) Source #

Compute the intersection of two pairs of nodes in the ring.

Math

area :: Fractional a => V2 a -> V2 a -> V2 a -> a Source #

Compute area of triangle.

area2X :: Fractional a => V2 a -> V2 a -> V2 a -> a Source #

Compute 2x area of triangle. This avoids a division.

isLeftTurn :: (Fractional a, Ord a, Epsilon a) => V2 a -> V2 a -> V2 a -> Bool Source #

Return True iff the line from p1 to p2 makes a left-turn to p3.

isLeftTurnOrLinear :: (Fractional a, Ord a, Epsilon a) => V2 a -> V2 a -> V2 a -> Bool Source #

Return True iff the line from p1 to p2 does not make a right-turn to p3.

isRightTurn :: (Fractional a, Ord a, Epsilon a) => V2 a -> V2 a -> V2 a -> Bool Source #

Return True iff the line from p1 to p2 makes a right-turn to p3.

isRightTurnOrLinear :: (Fractional a, Ord a, Epsilon a) => V2 a -> V2 a -> V2 a -> Bool Source #

Return True iff the line from p1 to p2 does not make a left-turn to p3.

direction :: Num a => V2 a -> V2 a -> V2 a -> a Source #

Compute the change in direction in a line between the three points.

isInside :: (Fractional a, Ord a) => V2 a -> V2 a -> V2 a -> V2 a -> Bool Source #

Returns True if the fourth argument is inside the triangle or on the border.

isInsideStrict :: (Fractional a, Ord a) => V2 a -> V2 a -> V2 a -> V2 a -> Bool Source #

Returns True iff the fourth argument is inside the triangle.

barycentricCoords :: Fractional a => V2 a -> V2 a -> V2 a -> V2 a -> (a, a, a) Source #

Compute relative coordinates inside the triangle. Invariant: a+b+c=1

rayIntersect :: (Fractional a, Ord a) => (V2 a, V2 a) -> (V2 a, V2 a) -> Maybe (V2 a) Source #

Compute intersection of two infinite lines.

isBetween :: (Ord a, Fractional a) => V2 a -> (V2 a, V2 a) -> Bool Source #

Returns True iff a point is on a line segment.

lineIntersect :: (Ord a, Fractional a) => (V2 a, V2 a) -> (V2 a, V2 a) -> Maybe (V2 a) Source #

Compute intersection of two line segments.

distSquared :: Num a => V2 a -> V2 a -> a Source #

Compute the square of the distance between two points.

approxDist :: (Real a, Fractional a) => V2 a -> V2 a -> a Source #

Approximate the distance between two points.

distance' :: (Real a, Fractional a) => V2 a -> V2 a -> Double Source #

Approximate the distance between two points.

triangleAngles :: V2 Double -> V2 Double -> V2 Double -> (Double, Double, Double) Source #

Approximate the angles of a triangle.

class Num a => Epsilon a where #

Provides a fairly subjective test to see if a quantity is near zero.

>>> nearZero (1e-11 :: Double)
False
>>> nearZero (1e-17 :: Double)
True
>>> nearZero (1e-5 :: Float)
False
>>> nearZero (1e-7 :: Float)
True

Methods

nearZero :: a -> Bool #

Determine if a quantity is near zero.

Instances

Instances details
Epsilon Double
abs a <= 1e-12
Instance details

Defined in Linear.Epsilon

Methods

nearZero :: Double -> Bool #

Epsilon Float
abs a <= 1e-6
Instance details

Defined in Linear.Epsilon

Methods

nearZero :: Float -> Bool #

Epsilon Rational Source # 
Instance details

Defined in Reanimate.Math.Common

Methods

nearZero :: Rational -> Bool #

Epsilon CFloat
abs a <= 1e-6
Instance details

Defined in Linear.Epsilon

Methods

nearZero :: CFloat -> Bool #

Epsilon CDouble
abs a <= 1e-12
Instance details

Defined in Linear.Epsilon

Methods

nearZero :: CDouble -> Bool #

(Epsilon a, RealFloat a) => Epsilon (Complex a) 
Instance details

Defined in Linear.Epsilon

Methods

nearZero :: Complex a -> Bool #

Epsilon a => Epsilon (Plucker a) 
Instance details

Defined in Linear.Plucker

Methods

nearZero :: Plucker a -> Bool #

(RealFloat a, Epsilon a) => Epsilon (Quaternion a) 
Instance details

Defined in Linear.Quaternion

Methods

nearZero :: Quaternion a -> Bool #

Epsilon (V0 a) 
Instance details

Defined in Linear.V0

Methods

nearZero :: V0 a -> Bool #

Epsilon a => Epsilon (V4 a) 
Instance details

Defined in Linear.V4

Methods

nearZero :: V4 a -> Bool #

Epsilon a => Epsilon (V3 a) 
Instance details

Defined in Linear.V3

Methods

nearZero :: V3 a -> Bool #

Epsilon a => Epsilon (V2 a) 
Instance details

Defined in Linear.V2

Methods

nearZero :: V2 a -> Bool #

Epsilon a => Epsilon (V1 a) 
Instance details

Defined in Linear.V1

Methods

nearZero :: V1 a -> Bool #

Epsilon (f a) => Epsilon (Point f a) 
Instance details

Defined in Linear.Affine

Methods

nearZero :: Point f a -> Bool #

(Dim n, Epsilon a) => Epsilon (V n a) 
Instance details

Defined in Linear.V

Methods

nearZero :: V n a -> Bool #

Orphan instances

Epsilon Rational Source # 
Instance details

Methods

nearZero :: Rational -> Bool #