reanimate-0.4.2.0: Animation library based on SVGs.

Copyright Written by David Himmelstrup Unlicense lemmih@gmail.com experimental POSIX None Haskell2010

Reanimate.Math.Common

Contents

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.

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
 abs a <= 1e-12 Instance detailsDefined in Linear.Epsilon Methods abs a <= 1e-6 Instance detailsDefined in Linear.Epsilon Methods Source # Instance detailsDefined in Reanimate.Math.Common Methods abs a <= 1e-6 Instance detailsDefined in Linear.Epsilon Methods abs a <= 1e-12 Instance detailsDefined in Linear.Epsilon Methods (Epsilon a, RealFloat a) => Epsilon (Complex a) Instance detailsDefined in Linear.Epsilon MethodsnearZero :: Complex a -> Bool # Epsilon a => Epsilon (Plucker a) Instance detailsDefined in Linear.Plucker MethodsnearZero :: Plucker a -> Bool # (RealFloat a, Epsilon a) => Epsilon (Quaternion a) Instance detailsDefined in Linear.Quaternion MethodsnearZero :: Quaternion a -> Bool # Epsilon (V0 a) Instance detailsDefined in Linear.V0 MethodsnearZero :: V0 a -> Bool # Epsilon a => Epsilon (V4 a) Instance detailsDefined in Linear.V4 MethodsnearZero :: V4 a -> Bool # Epsilon a => Epsilon (V3 a) Instance detailsDefined in Linear.V3 MethodsnearZero :: V3 a -> Bool # Epsilon a => Epsilon (V2 a) Instance detailsDefined in Linear.V2 MethodsnearZero :: V2 a -> Bool # Epsilon a => Epsilon (V1 a) Instance detailsDefined in Linear.V1 MethodsnearZero :: V1 a -> Bool # Epsilon (f a) => Epsilon (Point f a) Instance detailsDefined in Linear.Affine MethodsnearZero :: Point f a -> Bool # (Dim n, Epsilon a) => Epsilon (V n a) Instance detailsDefined in Linear.V MethodsnearZero :: V n a -> Bool #

# Orphan instances

 Source # Instance details Methods