hgeometry-0.7.0.0: Geometric Algorithms, Data structures, and Data types.

Data.Geometry

Description

Synopsis

# Documentation

imap :: (Vector v a, Vector v b) => (Int -> a -> b) -> v a -> v b #

Apply function to every element of the vector and its index.

replicate :: Vector v a => a -> v a #

Replicate value n times.

Examples:

>>> import Data.Vector.Fixed.Boxed (Vec2)
>>> replicate 1 :: Vec2 Int
fromList [1,1]

>>> replicate 2 :: (Double,Double,Double)
(2.0,2.0,2.0)

>>> import Data.Vector.Fixed.Boxed (Vec4)
>>> replicate "foo" :: Vec4 String
fromList ["foo","foo","foo","foo"]


distanceA :: (Floating a, Foldable (Diff p), Affine p) => p a -> p a -> a #

Distance between two points in an affine space

qdA :: (Affine p, Foldable (Diff p), Num a) => p a -> p a -> a #

Compute the quadrance of the difference (the square of the distance)

class Additive (Diff p) => Affine (p :: * -> *) where #

An affine space is roughly a vector space in which we have forgotten or at least pretend to have forgotten the origin.

a .+^ (b .-. a)  =  b@
(a .+^ u) .+^ v  =  a .+^ (u ^+^ v)@
(a .-. b) ^+^ v  =  (a .+^ v) .-. q@

Minimal complete definition

Associated Types

type Diff (p :: * -> *) :: * -> * #

Methods

(.-.) :: Num a => p a -> p a -> Diff p a infixl 6 #

Get the difference between two points as a vector offset.

(.+^) :: Num a => p a -> Diff p a -> p a infixl 6 #

Add a vector offset to a point.

(.-^) :: Num a => p a -> Diff p a -> p a infixl 6 #

Subtract a vector offset from a point.

Instances
 Affine [] Instance detailsDefined in Linear.Affine Associated Typestype Diff [] :: * -> * # Methods(.-.) :: Num a => [a] -> [a] -> Diff [] a #(.+^) :: Num a => [a] -> Diff [] a -> [a] #(.-^) :: Num a => [a] -> Diff [] a -> [a] # Instance detailsDefined in Linear.Affine Associated Typestype Diff Maybe :: * -> * # Methods(.-.) :: Num a => Maybe a -> Maybe a -> Diff Maybe a #(.+^) :: Num a => Maybe a -> Diff Maybe a -> Maybe a #(.-^) :: Num a => Maybe a -> Diff Maybe a -> Maybe a # Instance detailsDefined in Linear.Affine Associated Typestype Diff Complex :: * -> * # Methods(.-.) :: Num a => Complex a -> Complex a -> Diff Complex a #(.+^) :: Num a => Complex a -> Diff Complex a -> Complex a #(.-^) :: Num a => Complex a -> Diff Complex a -> Complex a # Instance detailsDefined in Linear.Affine Associated Typestype Diff ZipList :: * -> * # Methods(.-.) :: Num a => ZipList a -> ZipList a -> Diff ZipList a #(.+^) :: Num a => ZipList a -> Diff ZipList a -> ZipList a #(.-^) :: Num a => ZipList a -> Diff ZipList a -> ZipList a # Instance detailsDefined in Linear.Affine Associated Typestype Diff Identity :: * -> * # Methods(.-.) :: Num a => Identity a -> Identity a -> Diff Identity a #(.+^) :: Num a => Identity a -> Diff Identity a -> Identity a #(.-^) :: Num a => Identity a -> Diff Identity a -> Identity a # Instance detailsDefined in Linear.Affine Associated Typestype Diff IntMap :: * -> * # Methods(.-.) :: Num a => IntMap a -> IntMap a -> Diff IntMap a #(.+^) :: Num a => IntMap a -> Diff IntMap a -> IntMap a #(.-^) :: Num a => IntMap a -> Diff IntMap a -> IntMap a # Instance detailsDefined in Linear.Affine Associated Typestype Diff Vector :: * -> * # Methods(.-.) :: Num a => Vector a -> Vector a -> Diff Vector a #(.+^) :: Num a => Vector a -> Diff Vector a -> Vector a #(.-^) :: Num a => Vector a -> Diff Vector a -> Vector a # Instance detailsDefined in Linear.Affine Associated Typestype Diff Plucker :: * -> * # Methods(.-.) :: Num a => Plucker a -> Plucker a -> Diff Plucker a #(.+^) :: Num a => Plucker a -> Diff Plucker a -> Plucker a #(.-^) :: Num a => Plucker a -> Diff Plucker a -> Plucker a # Instance detailsDefined in Linear.Affine Associated Typestype Diff Quaternion :: * -> * # Methods(.-.) :: Num a => Quaternion a -> Quaternion a -> Diff Quaternion a #(.+^) :: Num a => Quaternion a -> Diff Quaternion a -> Quaternion a #(.-^) :: Num a => Quaternion a -> Diff Quaternion a -> Quaternion a # Instance detailsDefined in Linear.Affine Associated Typestype Diff V0 :: * -> * # Methods(.-.) :: Num a => V0 a -> V0 a -> Diff V0 a #(.+^) :: Num a => V0 a -> Diff V0 a -> V0 a #(.-^) :: Num a => V0 a -> Diff V0 a -> V0 a # Instance detailsDefined in Linear.Affine Associated Typestype Diff V4 :: * -> * # Methods(.-.) :: Num a => V4 a -> V4 a -> Diff V4 a #(.+^) :: Num a => V4 a -> Diff V4 a -> V4 a #(.-^) :: Num a => V4 a -> Diff V4 a -> V4 a # Instance detailsDefined in Linear.Affine Associated Typestype Diff V3 :: * -> * # Methods(.-.) :: Num a => V3 a -> V3 a -> Diff V3 a #(.+^) :: Num a => V3 a -> Diff V3 a -> V3 a #(.-^) :: Num a => V3 a -> Diff V3 a -> V3 a # Instance detailsDefined in Linear.Affine Associated Typestype Diff V2 :: * -> * # Methods(.-.) :: Num a => V2 a -> V2 a -> Diff V2 a #(.+^) :: Num a => V2 a -> Diff V2 a -> V2 a #(.-^) :: Num a => V2 a -> Diff V2 a -> V2 a # Instance detailsDefined in Linear.Affine Associated Typestype Diff V1 :: * -> * # Methods(.-.) :: Num a => V1 a -> V1 a -> Diff V1 a #(.+^) :: Num a => V1 a -> Diff V1 a -> V1 a #(.-^) :: Num a => V1 a -> Diff V1 a -> V1 a # (Eq k, Hashable k) => Affine (HashMap k) Instance detailsDefined in Linear.Affine Associated Typestype Diff (HashMap k) :: * -> * # Methods(.-.) :: Num a => HashMap k a -> HashMap k a -> Diff (HashMap k) a #(.+^) :: Num a => HashMap k a -> Diff (HashMap k) a -> HashMap k a #(.-^) :: Num a => HashMap k a -> Diff (HashMap k) a -> HashMap k a # Ord k => Affine (Map k) Instance detailsDefined in Linear.Affine Associated Typestype Diff (Map k) :: * -> * # Methods(.-.) :: Num a => Map k a -> Map k a -> Diff (Map k) a #(.+^) :: Num a => Map k a -> Diff (Map k) a -> Map k a #(.-^) :: Num a => Map k a -> Diff (Map k) a -> Map k a # Additive f => Affine (Point f) Instance detailsDefined in Linear.Affine Associated Typestype Diff (Point f) :: * -> * # Methods(.-.) :: Num a => Point f a -> Point f a -> Diff (Point f) a #(.+^) :: Num a => Point f a -> Diff (Point f) a -> Point f a #(.-^) :: Num a => Point f a -> Diff (Point f) a -> Point f a # Arity d => Affine (Vector d) # Instance detailsDefined in Data.Geometry.Vector.VectorFixed Associated Typestype Diff (Vector d) :: * -> * # Methods(.-.) :: Num a => Vector d a -> Vector d a -> Diff (Vector d) a #(.+^) :: Num a => Vector d a -> Diff (Vector d) a -> Vector d a #(.-^) :: Num a => Vector d a -> Diff (Vector d) a -> Vector d a # # Instance detailsDefined in Data.Geometry.Vector.VectorFamilyPeano Associated Typestype Diff (VectorFamily d) :: * -> * # Methods(.-.) :: Num a => VectorFamily d a -> VectorFamily d a -> Diff (VectorFamily d) a #(.+^) :: Num a => VectorFamily d a -> Diff (VectorFamily d) a -> VectorFamily d a #(.-^) :: Num a => VectorFamily d a -> Diff (VectorFamily d) a -> VectorFamily d a # Arity d => Affine (Vector d) # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Associated Typestype Diff (Vector d) :: * -> * # Methods(.-.) :: Num a => Vector d a -> Vector d a -> Diff (Vector d) a #(.+^) :: Num a => Vector d a -> Diff (Vector d) a -> Vector d a #(.-^) :: Num a => Vector d a -> Diff (Vector d) a -> Vector d a # Arity d => Affine (Point d) # Instance detailsDefined in Data.Geometry.Point Associated Typestype Diff (Point d) :: * -> * # Methods(.-.) :: Num a => Point d a -> Point d a -> Diff (Point d) a #(.+^) :: Num a => Point d a -> Diff (Point d) a -> Point d a #(.-^) :: Num a => Point d a -> Diff (Point d) a -> Point d a # Dim n => Affine (V n) Instance detailsDefined in Linear.Affine Associated Typestype Diff (V n) :: * -> * # Methods(.-.) :: Num a => V n a -> V n a -> Diff (V n) a #(.+^) :: Num a => V n a -> Diff (V n) a -> V n a #(.-^) :: Num a => V n a -> Diff (V n) a -> V n a # Affine ((->) b :: * -> *) Instance detailsDefined in Linear.Affine Associated Typestype Diff ((->) b) :: * -> * # Methods(.-.) :: Num a => (b -> a) -> (b -> a) -> Diff ((->) b) a #(.+^) :: Num a => (b -> a) -> Diff ((->) b) a -> b -> a #(.-^) :: Num a => (b -> a) -> Diff ((->) b) a -> b -> a #

dot :: (Metric f, Num a) => f a -> f a -> a #

Compute the inner product of two vectors or (equivalently) convert a vector f a into a covector f a -> a.

>>> V2 1 2 dot V2 3 4
11


norm :: (Metric f, Floating a) => f a -> a #

Compute the norm of a vector in a metric space

signorm :: (Metric f, Floating a) => f a -> f a #

Convert a non-zero vector to unit vector.

outer :: (Functor f, Functor g, Num a) => f a -> g a -> f (g a) #

Outer (tensor) product of two vectors

unit :: (Additive t, Num a) => ASetter' (t a) a -> t a #

Create a unit vector.

>>> unit _x :: V2 Int
V2 1 0


scaled :: (Traversable t, Num a) => t a -> t (t a) #

Produce a diagonal (scale) matrix from a vector.

>>> scaled (V2 2 3)
V2 (V2 2 0) (V2 0 3)


basisFor :: (Traversable t, Num a) => t b -> [t a] #

Produce a default basis for a vector space from which the argument is drawn.

basis :: (Additive t, Traversable t, Num a) => [t a] #

Produce a default basis for a vector space. If the dimensionality of the vector space is not statically known, see basisFor.

(^/) :: (Functor f, Fractional a) => f a -> a -> f a infixl 7 #

Compute division by a scalar on the right.

(^*) :: (Functor f, Num a) => f a -> a -> f a infixl 7 #

Compute the right scalar product

>>> V2 3 4 ^* 2
V2 6 8


(*^) :: (Functor f, Num a) => a -> f a -> f a infixl 7 #

Compute the left scalar product

>>> 2 *^ V2 3 4
V2 6 8


sumV :: (Foldable f, Additive v, Num a) => f (v a) -> v a #

Sum over multiple vectors

>>> sumV [V2 1 1, V2 3 4]
V2 4 5


negated :: (Functor f, Num a) => f a -> f a #

Compute the negation of a vector

>>> negated (V2 2 4)
V2 (-2) (-4)


newtype E (t :: * -> *) #

Basis element

Constructors

 E Fieldsel :: forall x (f :: * -> *). Functor f => (x -> f x) -> t x -> f (t x)
Instances
 Instance detailsDefined in Linear.Plucker Methodsimap :: (E Plucker -> a -> b) -> Plucker a -> Plucker b #imapped :: (Indexable (E Plucker) p, Settable f) => p a (f b) -> Plucker a -> f (Plucker b) # Instance detailsDefined in Linear.Quaternion Methodsimap :: (E Quaternion -> a -> b) -> Quaternion a -> Quaternion b #imapped :: (Indexable (E Quaternion) p, Settable f) => p a (f b) -> Quaternion a -> f (Quaternion b) # Instance detailsDefined in Linear.V0 Methodsimap :: (E V0 -> a -> b) -> V0 a -> V0 b #imapped :: (Indexable (E V0) p, Settable f) => p a (f b) -> V0 a -> f (V0 b) # Instance detailsDefined in Linear.V4 Methodsimap :: (E V4 -> a -> b) -> V4 a -> V4 b #imapped :: (Indexable (E V4) p, Settable f) => p a (f b) -> V4 a -> f (V4 b) # Instance detailsDefined in Linear.V3 Methodsimap :: (E V3 -> a -> b) -> V3 a -> V3 b #imapped :: (Indexable (E V3) p, Settable f) => p a (f b) -> V3 a -> f (V3 b) # Instance detailsDefined in Linear.V2 Methodsimap :: (E V2 -> a -> b) -> V2 a -> V2 b #imapped :: (Indexable (E V2) p, Settable f) => p a (f b) -> V2 a -> f (V2 b) # Instance detailsDefined in Linear.V1 Methodsimap :: (E V1 -> a -> b) -> V1 a -> V1 b #imapped :: (Indexable (E V1) p, Settable f) => p a (f b) -> V1 a -> f (V1 b) # Instance detailsDefined in Linear.Plucker MethodsifoldMap :: Monoid m => (E Plucker -> a -> m) -> Plucker a -> m #ifolded :: (Indexable (E Plucker) p, Contravariant f, Applicative f) => p a (f a) -> Plucker a -> f (Plucker a) #ifoldr :: (E Plucker -> a -> b -> b) -> b -> Plucker a -> b #ifoldl :: (E Plucker -> b -> a -> b) -> b -> Plucker a -> b #ifoldr' :: (E Plucker -> a -> b -> b) -> b -> Plucker a -> b #ifoldl' :: (E Plucker -> b -> a -> b) -> b -> Plucker a -> b # Instance detailsDefined in Linear.Quaternion MethodsifoldMap :: Monoid m => (E Quaternion -> a -> m) -> Quaternion a -> m #ifolded :: (Indexable (E Quaternion) p, Contravariant f, Applicative f) => p a (f a) -> Quaternion a -> f (Quaternion a) #ifoldr :: (E Quaternion -> a -> b -> b) -> b -> Quaternion a -> b #ifoldl :: (E Quaternion -> b -> a -> b) -> b -> Quaternion a -> b #ifoldr' :: (E Quaternion -> a -> b -> b) -> b -> Quaternion a -> b #ifoldl' :: (E Quaternion -> b -> a -> b) -> b -> Quaternion a -> b # Instance detailsDefined in Linear.V0 MethodsifoldMap :: Monoid m => (E V0 -> a -> m) -> V0 a -> m #ifolded :: (Indexable (E V0) p, Contravariant f, Applicative f) => p a (f a) -> V0 a -> f (V0 a) #ifoldr :: (E V0 -> a -> b -> b) -> b -> V0 a -> b #ifoldl :: (E V0 -> b -> a -> b) -> b -> V0 a -> b #ifoldr' :: (E V0 -> a -> b -> b) -> b -> V0 a -> b #ifoldl' :: (E V0 -> b -> a -> b) -> b -> V0 a -> b # Instance detailsDefined in Linear.V4 MethodsifoldMap :: Monoid m => (E V4 -> a -> m) -> V4 a -> m #ifolded :: (Indexable (E V4) p, Contravariant f, Applicative f) => p a (f a) -> V4 a -> f (V4 a) #ifoldr :: (E V4 -> a -> b -> b) -> b -> V4 a -> b #ifoldl :: (E V4 -> b -> a -> b) -> b -> V4 a -> b #ifoldr' :: (E V4 -> a -> b -> b) -> b -> V4 a -> b #ifoldl' :: (E V4 -> b -> a -> b) -> b -> V4 a -> b # Instance detailsDefined in Linear.V3 MethodsifoldMap :: Monoid m => (E V3 -> a -> m) -> V3 a -> m #ifolded :: (Indexable (E V3) p, Contravariant f, Applicative f) => p a (f a) -> V3 a -> f (V3 a) #ifoldr :: (E V3 -> a -> b -> b) -> b -> V3 a -> b #ifoldl :: (E V3 -> b -> a -> b) -> b -> V3 a -> b #ifoldr' :: (E V3 -> a -> b -> b) -> b -> V3 a -> b #ifoldl' :: (E V3 -> b -> a -> b) -> b -> V3 a -> b # Instance detailsDefined in Linear.V2 MethodsifoldMap :: Monoid m => (E V2 -> a -> m) -> V2 a -> m #ifolded :: (Indexable (E V2) p, Contravariant f, Applicative f) => p a (f a) -> V2 a -> f (V2 a) #ifoldr :: (E V2 -> a -> b -> b) -> b -> V2 a -> b #ifoldl :: (E V2 -> b -> a -> b) -> b -> V2 a -> b #ifoldr' :: (E V2 -> a -> b -> b) -> b -> V2 a -> b #ifoldl' :: (E V2 -> b -> a -> b) -> b -> V2 a -> b # Instance detailsDefined in Linear.V1 MethodsifoldMap :: Monoid m => (E V1 -> a -> m) -> V1 a -> m #ifolded :: (Indexable (E V1) p, Contravariant f, Applicative f) => p a (f a) -> V1 a -> f (V1 a) #ifoldr :: (E V1 -> a -> b -> b) -> b -> V1 a -> b #ifoldl :: (E V1 -> b -> a -> b) -> b -> V1 a -> b #ifoldr' :: (E V1 -> a -> b -> b) -> b -> V1 a -> b #ifoldl' :: (E V1 -> b -> a -> b) -> b -> V1 a -> b # Instance detailsDefined in Linear.Plucker Methodsitraverse :: Applicative f => (E Plucker -> a -> f b) -> Plucker a -> f (Plucker b) #itraversed :: (Indexable (E Plucker) p, Applicative f) => p a (f b) -> Plucker a -> f (Plucker b) # Instance detailsDefined in Linear.Quaternion Methodsitraverse :: Applicative f => (E Quaternion -> a -> f b) -> Quaternion a -> f (Quaternion b) #itraversed :: (Indexable (E Quaternion) p, Applicative f) => p a (f b) -> Quaternion a -> f (Quaternion b) # Instance detailsDefined in Linear.V0 Methodsitraverse :: Applicative f => (E V0 -> a -> f b) -> V0 a -> f (V0 b) #itraversed :: (Indexable (E V0) p, Applicative f) => p a (f b) -> V0 a -> f (V0 b) # Instance detailsDefined in Linear.V4 Methodsitraverse :: Applicative f => (E V4 -> a -> f b) -> V4 a -> f (V4 b) #itraversed :: (Indexable (E V4) p, Applicative f) => p a (f b) -> V4 a -> f (V4 b) # Instance detailsDefined in Linear.V3 Methodsitraverse :: Applicative f => (E V3 -> a -> f b) -> V3 a -> f (V3 b) #itraversed :: (Indexable (E V3) p, Applicative f) => p a (f b) -> V3 a -> f (V3 b) # Instance detailsDefined in Linear.V2 Methodsitraverse :: Applicative f => (E V2 -> a -> f b) -> V2 a -> f (V2 b) #itraversed :: (Indexable (E V2) p, Applicative f) => p a (f b) -> V2 a -> f (V2 b) # Instance detailsDefined in Linear.V1 Methodsitraverse :: Applicative f => (E V1 -> a -> f b) -> V1 a -> f (V1 b) #itraversed :: (Indexable (E V1) p, Applicative f) => p a (f b) -> V1 a -> f (V1 b) #

class Functor f => Additive (f :: * -> *) where #

Methods

zero :: Num a => f a #

The zero vector

(^+^) :: Num a => f a -> f a -> f a infixl 6 #

Compute the sum of two vectors

>>> V2 1 2 ^+^ V2 3 4
V2 4 6


(^-^) :: Num a => f a -> f a -> f a infixl 6 #

Compute the difference between two vectors

>>> V2 4 5 ^-^ V2 3 1
V2 1 4


lerp :: Num a => a -> f a -> f a -> f a #

Linearly interpolate between two vectors.

liftU2 :: (a -> a -> a) -> f a -> f a -> f a #

Apply a function to merge the 'non-zero' components of two vectors, unioning the rest of the values.

• For a dense vector this is equivalent to liftA2.
• For a sparse vector this is equivalent to unionWith.

liftI2 :: (a -> b -> c) -> f a -> f b -> f c #

Apply a function to the components of two vectors.

• For a dense vector this is equivalent to liftA2.
• For a sparse vector this is equivalent to intersectionWith.
Instances
 Additive [] Instance detailsDefined in Linear.Vector Methodszero :: Num a => [a] #(^+^) :: Num a => [a] -> [a] -> [a] #(^-^) :: Num a => [a] -> [a] -> [a] #lerp :: Num a => a -> [a] -> [a] -> [a] #liftU2 :: (a -> a -> a) -> [a] -> [a] -> [a] #liftI2 :: (a -> b -> c) -> [a] -> [b] -> [c] # Instance detailsDefined in Linear.Vector Methodszero :: Num a => Maybe a #(^+^) :: Num a => Maybe a -> Maybe a -> Maybe a #(^-^) :: Num a => Maybe a -> Maybe a -> Maybe a #lerp :: Num a => a -> Maybe a -> Maybe a -> Maybe a #liftU2 :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a #liftI2 :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c # Instance detailsDefined in Linear.Vector Methodszero :: Num a => Complex a #(^+^) :: Num a => Complex a -> Complex a -> Complex a #(^-^) :: Num a => Complex a -> Complex a -> Complex a #lerp :: Num a => a -> Complex a -> Complex a -> Complex a #liftU2 :: (a -> a -> a) -> Complex a -> Complex a -> Complex a #liftI2 :: (a -> b -> c) -> Complex a -> Complex b -> Complex c # Instance detailsDefined in Linear.Vector Methodszero :: Num a => ZipList a #(^+^) :: Num a => ZipList a -> ZipList a -> ZipList a #(^-^) :: Num a => ZipList a -> ZipList a -> ZipList a #lerp :: Num a => a -> ZipList a -> ZipList a -> ZipList a #liftU2 :: (a -> a -> a) -> ZipList a -> ZipList a -> ZipList a #liftI2 :: (a -> b -> c) -> ZipList a -> ZipList b -> ZipList c # Instance detailsDefined in Linear.Vector Methodszero :: Num a => Identity a #(^+^) :: Num a => Identity a -> Identity a -> Identity a #(^-^) :: Num a => Identity a -> Identity a -> Identity a #lerp :: Num a => a -> Identity a -> Identity a -> Identity a #liftU2 :: (a -> a -> a) -> Identity a -> Identity a -> Identity a #liftI2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity c # Instance detailsDefined in Linear.Vector Methodszero :: Num a => IntMap a #(^+^) :: Num a => IntMap a -> IntMap a -> IntMap a #(^-^) :: Num a => IntMap a -> IntMap a -> IntMap a #lerp :: Num a => a -> IntMap a -> IntMap a -> IntMap a #liftU2 :: (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a #liftI2 :: (a -> b -> c) -> IntMap a -> IntMap b -> IntMap c # Instance detailsDefined in Linear.Vector Methodszero :: Num a => Vector a #(^+^) :: Num a => Vector a -> Vector a -> Vector a #(^-^) :: Num a => Vector a -> Vector a -> Vector a #lerp :: Num a => a -> Vector a -> Vector a -> Vector a #liftU2 :: (a -> a -> a) -> Vector a -> Vector a -> Vector a #liftI2 :: (a -> b -> c) -> Vector a -> Vector b -> Vector c # Instance detailsDefined in Linear.Plucker Methodszero :: Num a => Plucker a #(^+^) :: Num a => Plucker a -> Plucker a -> Plucker a #(^-^) :: Num a => Plucker a -> Plucker a -> Plucker a #lerp :: Num a => a -> Plucker a -> Plucker a -> Plucker a #liftU2 :: (a -> a -> a) -> Plucker a -> Plucker a -> Plucker a #liftI2 :: (a -> b -> c) -> Plucker a -> Plucker b -> Plucker c # Instance detailsDefined in Linear.Quaternion Methodszero :: Num a => Quaternion a #(^+^) :: Num a => Quaternion a -> Quaternion a -> Quaternion a #(^-^) :: Num a => Quaternion a -> Quaternion a -> Quaternion a #lerp :: Num a => a -> Quaternion a -> Quaternion a -> Quaternion a #liftU2 :: (a -> a -> a) -> Quaternion a -> Quaternion a -> Quaternion a #liftI2 :: (a -> b -> c) -> Quaternion a -> Quaternion b -> Quaternion c # Instance detailsDefined in Linear.V0 Methodszero :: Num a => V0 a #(^+^) :: Num a => V0 a -> V0 a -> V0 a #(^-^) :: Num a => V0 a -> V0 a -> V0 a #lerp :: Num a => a -> V0 a -> V0 a -> V0 a #liftU2 :: (a -> a -> a) -> V0 a -> V0 a -> V0 a #liftI2 :: (a -> b -> c) -> V0 a -> V0 b -> V0 c # Instance detailsDefined in Linear.V4 Methodszero :: Num a => V4 a #(^+^) :: Num a => V4 a -> V4 a -> V4 a #(^-^) :: Num a => V4 a -> V4 a -> V4 a #lerp :: Num a => a -> V4 a -> V4 a -> V4 a #liftU2 :: (a -> a -> a) -> V4 a -> V4 a -> V4 a #liftI2 :: (a -> b -> c) -> V4 a -> V4 b -> V4 c # Instance detailsDefined in Linear.V3 Methodszero :: Num a => V3 a #(^+^) :: Num a => V3 a -> V3 a -> V3 a #(^-^) :: Num a => V3 a -> V3 a -> V3 a #lerp :: Num a => a -> V3 a -> V3 a -> V3 a #liftU2 :: (a -> a -> a) -> V3 a -> V3 a -> V3 a #liftI2 :: (a -> b -> c) -> V3 a -> V3 b -> V3 c # Instance detailsDefined in Linear.V2 Methodszero :: Num a => V2 a #(^+^) :: Num a => V2 a -> V2 a -> V2 a #(^-^) :: Num a => V2 a -> V2 a -> V2 a #lerp :: Num a => a -> V2 a -> V2 a -> V2 a #liftU2 :: (a -> a -> a) -> V2 a -> V2 a -> V2 a #liftI2 :: (a -> b -> c) -> V2 a -> V2 b -> V2 c # Instance detailsDefined in Linear.V1 Methodszero :: Num a => V1 a #(^+^) :: Num a => V1 a -> V1 a -> V1 a #(^-^) :: Num a => V1 a -> V1 a -> V1 a #lerp :: Num a => a -> V1 a -> V1 a -> V1 a #liftU2 :: (a -> a -> a) -> V1 a -> V1 a -> V1 a #liftI2 :: (a -> b -> c) -> V1 a -> V1 b -> V1 c # (Eq k, Hashable k) => Additive (HashMap k) Instance detailsDefined in Linear.Vector Methodszero :: Num a => HashMap k a #(^+^) :: Num a => HashMap k a -> HashMap k a -> HashMap k a #(^-^) :: Num a => HashMap k a -> HashMap k a -> HashMap k a #lerp :: Num a => a -> HashMap k a -> HashMap k a -> HashMap k a #liftU2 :: (a -> a -> a) -> HashMap k a -> HashMap k a -> HashMap k a #liftI2 :: (a -> b -> c) -> HashMap k a -> HashMap k b -> HashMap k c # Ord k => Additive (Map k) Instance detailsDefined in Linear.Vector Methodszero :: Num a => Map k a #(^+^) :: Num a => Map k a -> Map k a -> Map k a #(^-^) :: Num a => Map k a -> Map k a -> Map k a #lerp :: Num a => a -> Map k a -> Map k a -> Map k a #liftU2 :: (a -> a -> a) -> Map k a -> Map k a -> Map k a #liftI2 :: (a -> b -> c) -> Map k a -> Map k b -> Map k c # Additive f => Additive (Point f) Instance detailsDefined in Linear.Affine Methodszero :: Num a => Point f a #(^+^) :: Num a => Point f a -> Point f a -> Point f a #(^-^) :: Num a => Point f a -> Point f a -> Point f a #lerp :: Num a => a -> Point f a -> Point f a -> Point f a #liftU2 :: (a -> a -> a) -> Point f a -> Point f a -> Point f a #liftI2 :: (a -> b -> c) -> Point f a -> Point f b -> Point f c # Arity d => Additive (Vector d) # Instance detailsDefined in Data.Geometry.Vector.VectorFixed Methodszero :: Num a => Vector d a #(^+^) :: Num a => Vector d a -> Vector d a -> Vector d a #(^-^) :: Num a => Vector d a -> Vector d a -> Vector d a #lerp :: Num a => a -> Vector d a -> Vector d a -> Vector d a #liftU2 :: (a -> a -> a) -> Vector d a -> Vector d a -> Vector d a #liftI2 :: (a -> b -> c) -> Vector d a -> Vector d b -> Vector d c # # Instance detailsDefined in Data.Geometry.Vector.VectorFamilyPeano Methodszero :: Num a => VectorFamily d a #(^+^) :: Num a => VectorFamily d a -> VectorFamily d a -> VectorFamily d a #(^-^) :: Num a => VectorFamily d a -> VectorFamily d a -> VectorFamily d a #lerp :: Num a => a -> VectorFamily d a -> VectorFamily d a -> VectorFamily d a #liftU2 :: (a -> a -> a) -> VectorFamily d a -> VectorFamily d a -> VectorFamily d a #liftI2 :: (a -> b -> c) -> VectorFamily d a -> VectorFamily d b -> VectorFamily d c # Arity d => Additive (Vector d) # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methodszero :: Num a => Vector d a #(^+^) :: Num a => Vector d a -> Vector d a -> Vector d a #(^-^) :: Num a => Vector d a -> Vector d a -> Vector d a #lerp :: Num a => a -> Vector d a -> Vector d a -> Vector d a #liftU2 :: (a -> a -> a) -> Vector d a -> Vector d a -> Vector d a #liftI2 :: (a -> b -> c) -> Vector d a -> Vector d b -> Vector d c # Dim n => Additive (V n) Instance detailsDefined in Linear.V Methodszero :: Num a => V n a #(^+^) :: Num a => V n a -> V n a -> V n a #(^-^) :: Num a => V n a -> V n a -> V n a #lerp :: Num a => a -> V n a -> V n a -> V n a #liftU2 :: (a -> a -> a) -> V n a -> V n a -> V n a #liftI2 :: (a -> b -> c) -> V n a -> V n b -> V n c # Additive ((->) b :: * -> *) Instance detailsDefined in Linear.Vector Methodszero :: Num a => b -> a #(^+^) :: Num a => (b -> a) -> (b -> a) -> b -> a #(^-^) :: Num a => (b -> a) -> (b -> a) -> b -> a #lerp :: Num a => a -> (b -> a) -> (b -> a) -> b -> a #liftU2 :: (a -> a -> a) -> (b -> a) -> (b -> a) -> b -> a #liftI2 :: (a -> b0 -> c) -> (b -> a) -> (b -> b0) -> b -> c #

data C (n :: Nat) Source #

A proxy which can be used for the coordinates.

Constructors

 C
Instances
 Eq (C n) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFixed Methods(==) :: C n -> C n -> Bool #(/=) :: C n -> C n -> Bool # Ord (C n) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFixed Methodscompare :: C n -> C n -> Ordering #(<) :: C n -> C n -> Bool #(<=) :: C n -> C n -> Bool #(>) :: C n -> C n -> Bool #(>=) :: C n -> C n -> Bool #max :: C n -> C n -> C n #min :: C n -> C n -> C n # Read (C n) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFixed MethodsreadsPrec :: Int -> ReadS (C n) #readList :: ReadS [C n] #readPrec :: ReadPrec (C n) # Show (C n) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFixed MethodsshowsPrec :: Int -> C n -> ShowS #show :: C n -> String #showList :: [C n] -> ShowS #

newtype Vector (d :: Nat) (r :: *) Source #

Datatype representing d dimensional vectors. The default implementation is based n VectorFixed. However, for small vectors we automatically select a more efficient representation.

Constructors

 MKVector Fields_unV :: VectorFamily (Peano d) r
Instances
 Arity d => Functor (Vector d) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methodsfmap :: (a -> b) -> Vector d a -> Vector d b #(<$) :: a -> Vector d b -> Vector d a # Arity d => Applicative (Vector d) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methodspure :: a -> Vector d a #(<*>) :: Vector d (a -> b) -> Vector d a -> Vector d b #liftA2 :: (a -> b -> c) -> Vector d a -> Vector d b -> Vector d c #(*>) :: Vector d a -> Vector d b -> Vector d b #(<*) :: Vector d a -> Vector d b -> Vector d a # Arity d => Foldable (Vector d) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methodsfold :: Monoid m => Vector d m -> m #foldMap :: Monoid m => (a -> m) -> Vector d a -> m #foldr :: (a -> b -> b) -> b -> Vector d a -> b #foldr' :: (a -> b -> b) -> b -> Vector d a -> b #foldl :: (b -> a -> b) -> b -> Vector d a -> b #foldl' :: (b -> a -> b) -> b -> Vector d a -> b #foldr1 :: (a -> a -> a) -> Vector d a -> a #foldl1 :: (a -> a -> a) -> Vector d a -> a #toList :: Vector d a -> [a] #null :: Vector d a -> Bool #length :: Vector d a -> Int #elem :: Eq a => a -> Vector d a -> Bool #maximum :: Ord a => Vector d a -> a #minimum :: Ord a => Vector d a -> a #sum :: Num a => Vector d a -> a #product :: Num a => Vector d a -> a # Arity d => Traversable (Vector d) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methodstraverse :: Applicative f => (a -> f b) -> Vector d a -> f (Vector d b) #sequenceA :: Applicative f => Vector d (f a) -> f (Vector d a) #mapM :: Monad m => (a -> m b) -> Vector d a -> m (Vector d b) #sequence :: Monad m => Vector d (m a) -> m (Vector d a) # Arity d => Affine (Vector d) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Associated Typestype Diff (Vector d) :: * -> * # Methods(.-.) :: Num a => Vector d a -> Vector d a -> Diff (Vector d) a #(.+^) :: Num a => Vector d a -> Diff (Vector d) a -> Vector d a #(.-^) :: Num a => Vector d a -> Diff (Vector d) a -> Vector d a # Arity d => Metric (Vector d) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methodsdot :: Num a => Vector d a -> Vector d a -> a #quadrance :: Num a => Vector d a -> a #qd :: Num a => Vector d a -> Vector d a -> a #distance :: Floating a => Vector d a -> Vector d a -> a #norm :: Floating a => Vector d a -> a #signorm :: Floating a => Vector d a -> Vector d a # Arity d => Additive (Vector d) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methodszero :: Num a => Vector d a #(^+^) :: Num a => Vector d a -> Vector d a -> Vector d a #(^-^) :: Num a => Vector d a -> Vector d a -> Vector d a #lerp :: Num a => a -> Vector d a -> Vector d a -> Vector d a #liftU2 :: (a -> a -> a) -> Vector d a -> Vector d a -> Vector d a #liftI2 :: (a -> b -> c) -> Vector d a -> Vector d b -> Vector d c # Arity d => Vector (Vector d) r Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methodsconstruct :: Fun (Peano (Dim (Vector d))) r (Vector d r) #inspect :: Vector d r -> Fun (Peano (Dim (Vector d))) r b -> b #basicIndex :: Vector d r -> Int -> r # (Eq r, Arity d) => Eq (Vector d r) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methods(==) :: Vector d r -> Vector d r -> Bool #(/=) :: Vector d r -> Vector d r -> Bool # (Ord r, Arity d) => Ord (Vector d r) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methodscompare :: Vector d r -> Vector d r -> Ordering #(<) :: Vector d r -> Vector d r -> Bool #(<=) :: Vector d r -> Vector d r -> Bool #(>) :: Vector d r -> Vector d r -> Bool #(>=) :: Vector d r -> Vector d r -> Bool #max :: Vector d r -> Vector d r -> Vector d r #min :: Vector d r -> Vector d r -> Vector d r # (Arity d, Show r) => Show (Vector d r) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily MethodsshowsPrec :: Int -> Vector d r -> ShowS #show :: Vector d r -> String #showList :: [Vector d r] -> ShowS # (Arbitrary r, Arity d) => Arbitrary (Vector d r) # Instance detailsDefined in Test.QuickCheck.HGeometryInstances Methodsarbitrary :: Gen (Vector d r) #shrink :: Vector d r -> [Vector d r] # (ToJSON r, Arity d) => ToJSON (Vector d r) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily MethodstoJSON :: Vector d r -> Value #toEncoding :: Vector d r -> Encoding #toJSONList :: [Vector d r] -> Value #toEncodingList :: [Vector d r] -> Encoding # (FromJSON r, Arity d) => FromJSON (Vector d r) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily MethodsparseJSON :: Value -> Parser (Vector d r) #parseJSONList :: Value -> Parser [Vector d r] # (NFData r, Arity d) => NFData (Vector d r) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methodsrnf :: Vector d r -> () # Arity d => Ixed (Vector d r) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily Methodsix :: Index (Vector d r) -> Traversal' (Vector d r) (IxValue (Vector d r)) # (Fractional r, Arity d, Arity (d + 1)) => IsTransformable (Vector d r) Source # Instance detailsDefined in Data.Geometry.Transformation MethodstransformBy :: Transformation (Dimension (Vector d r)) (NumType (Vector d r)) -> Vector d r -> Vector d r Source # type Dim (Vector d) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily type Dim (Vector d) = FromPeano (Peano d) type Diff (Vector d) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily type Diff (Vector d) = Diff (VectorFamily (Peano d)) type Index (Vector d r) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily type Index (Vector d r) = Int type IxValue (Vector d r) Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily type IxValue (Vector d r) = r type NumType (Vector d r) Source # Instance detailsDefined in Data.Geometry.Vector type NumType (Vector d r) = r type Dimension (Vector d r) Source # Instance detailsDefined in Data.Geometry.Vector type Dimension (Vector d r) = d pattern Vector4 :: r -> r -> r -> r -> Vector 4 r Source # pattern Vector3 :: r -> r -> r -> Vector 3 r Source # pattern Vector2 :: r -> r -> Vector 2 r Source # pattern Vector1 :: r -> Vector 1 r Source # pattern Vector :: VectorFamilyF (Peano d) r -> Vector d r Source # unV :: Lens (Vector d r) (Vector d s) (VectorFamily (Peano d) r) (VectorFamily (Peano d) s) Source # vectorFromList :: Arity d => [r] -> Maybe (Vector d r) Source # destruct :: (Arity d, Arity (d + 1)) => Vector (d + 1) r -> (r, Vector d r) Source # element :: forall proxy i d r. (Arity d, KnownNat i, (i + 1) <= d) => proxy i -> Lens' (Vector d r) r Source # Lens into the i th element element' :: forall d r. Arity d => Int -> Traversal' (Vector d r) r Source # Similar to element above. Except that we don't have a static guarantee that the index is in bounds. Hence, we can only return a Traversal snoc :: (Arity (d + 1), Arity d) => Vector d r -> r -> Vector (d + 1) r Source # Add an element at the back of the vector init :: (Arity d, Arity (d + 1)) => Vector (d + 1) r -> Vector d r Source # Get a vector of the first d - 1 elements. prefix :: forall i d r. (Arity d, Arity i, i <= d) => Vector d r -> Vector i r Source # Get a prefix of i elements of a vector cross :: Num r => Vector 3 r -> Vector 3 r -> Vector 3 r Source # Cross product of two three-dimensional vectors isScalarMultipleOf :: (Eq r, Fractional r, Arity d) => Vector d r -> Vector d r -> Bool Source # Test if v is a scalar multiple of u. >>> Vector2 1 1 isScalarMultipleOf Vector2 10 10 True >>> Vector2 1 1 isScalarMultipleOf Vector2 10 1 False >>> Vector2 1 1 isScalarMultipleOf Vector2 11.1 11.1 True >>> Vector2 1 1 isScalarMultipleOf Vector2 11.1 11.2 False >>> Vector2 2 1 isScalarMultipleOf Vector2 11.1 11.2 False >>> Vector2 2 1 isScalarMultipleOf Vector2 4 2 True >>> Vector2 2 1 isScalarMultipleOf Vector2 4 0 False  scalarMultiple :: (Eq r, Fractional r, Arity d) => Vector d r -> Vector d r -> Maybe r Source # Get the scalar labmda s.t. v = lambda * u (if it exists) newtype PolyLine d p r Source # A Poly line in R^d Constructors  PolyLine Fields_points :: Seq2 (Point d r :+ p) Instances  Arity d => Bifunctor (PolyLine d) Source # Instance detailsDefined in Data.Geometry.PolyLine Methodsbimap :: (a -> b) -> (c -> d0) -> PolyLine d a c -> PolyLine d b d0 #first :: (a -> b) -> PolyLine d a c -> PolyLine d b c #second :: (b -> c) -> PolyLine d a b -> PolyLine d a c # Arity d => Functor (PolyLine d p) Source # Instance detailsDefined in Data.Geometry.PolyLine Methodsfmap :: (a -> b) -> PolyLine d p a -> PolyLine d p b #(<$) :: a -> PolyLine d p b -> PolyLine d p a # PointFunctor (PolyLine d p) Source # Instance detailsDefined in Data.Geometry.PolyLine Methodspmap :: (Point (Dimension (PolyLine d p r)) r -> Point (Dimension (PolyLine d p s)) s) -> PolyLine d p r -> PolyLine d p s Source # (Eq r, Eq p, Arity d) => Eq (PolyLine d p r) Source # Instance detailsDefined in Data.Geometry.PolyLine Methods(==) :: PolyLine d p r -> PolyLine d p r -> Bool #(/=) :: PolyLine d p r -> PolyLine d p r -> Bool # (Ord r, Ord p, Arity d) => Ord (PolyLine d p r) Source # Instance detailsDefined in Data.Geometry.PolyLine Methodscompare :: PolyLine d p r -> PolyLine d p r -> Ordering #(<) :: PolyLine d p r -> PolyLine d p r -> Bool #(<=) :: PolyLine d p r -> PolyLine d p r -> Bool #(>) :: PolyLine d p r -> PolyLine d p r -> Bool #(>=) :: PolyLine d p r -> PolyLine d p r -> Bool #max :: PolyLine d p r -> PolyLine d p r -> PolyLine d p r #min :: PolyLine d p r -> PolyLine d p r -> PolyLine d p r # (Show r, Show p, Arity d) => Show (PolyLine d p r) Source # Instance detailsDefined in Data.Geometry.PolyLine MethodsshowsPrec :: Int -> PolyLine d p r -> ShowS #show :: PolyLine d p r -> String #showList :: [PolyLine d p r] -> ShowS # Semigroup (PolyLine d p r) Source # Instance detailsDefined in Data.Geometry.PolyLine Methods(<>) :: PolyLine d p r -> PolyLine d p r -> PolyLine d p r #sconcat :: NonEmpty (PolyLine d p r) -> PolyLine d p r #stimes :: Integral b => b -> PolyLine d p r -> PolyLine d p r # (Fractional r, Arity d, Arity (d + 1)) => IsTransformable (PolyLine d p r) Source # Instance detailsDefined in Data.Geometry.PolyLine MethodstransformBy :: Transformation (Dimension (PolyLine d p r)) (NumType (PolyLine d p r)) -> PolyLine d p r -> PolyLine d p r Source # Arity d => IsBoxable (PolyLine d p r) Source # Instance detailsDefined in Data.Geometry.PolyLine MethodsboundingBox :: PolyLine d p r -> Box (Dimension (PolyLine d p r)) () (NumType (PolyLine d p r)) Source # (IpeWriteText r, IpeWrite p) => IpeWrite (PolyLine 2 p r) Source # Instance detailsDefined in Data.Geometry.Ipe.Writer MethodsipeWrite :: PolyLine 2 p r -> Maybe (Node Text Text) Source # IpeWriteText r => IpeWriteText (PolyLine 2 () r) Source # Instance detailsDefined in Data.Geometry.Ipe.Writer MethodsipeWriteText :: PolyLine 2 () r -> Maybe Text Source # HasDefaultFromIpe (PolyLine 2 () r) Source # Instance detailsDefined in Data.Geometry.Ipe.FromIpe Associated Typestype DefaultFromIpe (PolyLine 2 () r) :: * -> * Source # MethodsdefaultFromIpe :: r0 ~ NumType (PolyLine 2 () r) => Prism' (IpeObject r0) (PolyLine 2 () r :+ IpeAttributes (DefaultFromIpe (PolyLine 2 () r)) r0) Source # HasDefaultIpeOut (PolyLine 2 p r) Source # Instance detailsDefined in Data.Geometry.Ipe.IpeOut Associated Typestype DefaultIpeOut (PolyLine 2 p r) :: * -> * Source # MethodsdefaultIpeOut :: IpeOut (PolyLine 2 p r) (IpeObject' (DefaultIpeOut (PolyLine 2 p r)) (NumType (PolyLine 2 p r))) Source # type NumType (PolyLine d p r) Source # Instance detailsDefined in Data.Geometry.PolyLine type NumType (PolyLine d p r) = r type Dimension (PolyLine d p r) Source # Instance detailsDefined in Data.Geometry.PolyLine type Dimension (PolyLine d p r) = d type DefaultFromIpe (PolyLine 2 () r) Source # Instance detailsDefined in Data.Geometry.Ipe.FromIpe type DefaultFromIpe (PolyLine 2 () r) = Path type DefaultIpeOut (PolyLine 2 p r) Source # Instance detailsDefined in Data.Geometry.Ipe.IpeOut type DefaultIpeOut (PolyLine 2 p r) = Path

points :: forall d p r d p r. Iso (PolyLine d p r) (PolyLine d p r) (Seq2 ((:+) (Point d r) p)) (Seq2 ((:+) (Point d r) p)) Source #

fromPoints' :: Monoid p => [Point d r] -> PolyLine d p r Source #

pre: The input list contains at least two points. All extra vields are initialized with mempty.

fromLineSegment :: LineSegment d p r -> PolyLine d p r Source #

We consider the line-segment as closed.

asLineSegment :: PolyLine d p r -> LineSegment d p r Source #

Convert to a closed line segment by taking the first two points.

asLineSegment' :: PolyLine d p r -> Maybe (LineSegment d p r) Source #

Stricter version of asLineSegment that fails if the Polyline contains more than two points.

type SomePolygon p r = Either (Polygon Simple p r) (Polygon Multi p r) Source #

Either a simple or multipolygon

data Polygon (t :: PolygonType) p r where Source #

Constructors

 SimplePolygon :: CSeq (Point 2 r :+ p) -> Polygon Simple p r MultiPolygon :: CSeq (Point 2 r :+ p) -> [Polygon Simple p r] -> Polygon Multi p r
Instances
 Source # Instance detailsDefined in Data.Geometry.Polygon Methodsbitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Polygon t a b -> f (Polygon t c d) # Source # Instance detailsDefined in Data.Geometry.Polygon Methodsbifold :: Monoid m => Polygon t m m -> m #bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Polygon t a b -> m #bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Polygon t a b -> c #bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Polygon t a b -> c # Source # Instance detailsDefined in Data.Geometry.Polygon Methodsbimap :: (a -> b) -> (c -> d) -> Polygon t a c -> Polygon t b d #first :: (a -> b) -> Polygon t a c -> Polygon t b c #second :: (b -> c) -> Polygon t a b -> Polygon t a c # PointFunctor (Polygon t p) Source # Instance detailsDefined in Data.Geometry.Polygon Methodspmap :: (Point (Dimension (Polygon t p r)) r -> Point (Dimension (Polygon t p s)) s) -> Polygon t p r -> Polygon t p s Source # Source # Instance detailsDefined in Data.Geometry.Ipe.FromIpe Associated Typestype DefaultFromIpe (MultiPolygon () r) :: * -> * Source # MethodsdefaultFromIpe :: r0 ~ NumType (MultiPolygon () r) => Prism' (IpeObject r0) (MultiPolygon () r :+ IpeAttributes (DefaultFromIpe (MultiPolygon () r)) r0) Source # Source # Instance detailsDefined in Data.Geometry.Ipe.FromIpe Associated Typestype DefaultFromIpe (SimplePolygon () r) :: * -> * Source # MethodsdefaultFromIpe :: r0 ~ NumType (SimplePolygon () r) => Prism' (IpeObject r0) (SimplePolygon () r :+ IpeAttributes (DefaultFromIpe (SimplePolygon () r)) r0) Source # Source # Instance detailsDefined in Data.Geometry.Ipe.IpeOut Associated Typestype DefaultIpeOut (SomePolygon p r) :: * -> * Source # MethodsdefaultIpeOut :: IpeOut (SomePolygon p r) (IpeObject' (DefaultIpeOut (SomePolygon p r)) (NumType (SomePolygon p r))) Source # (Eq p, Eq r) => Eq (Polygon t p r) Source # Instance detailsDefined in Data.Geometry.Polygon Methods(==) :: Polygon t p r -> Polygon t p r -> Bool #(/=) :: Polygon t p r -> Polygon t p r -> Bool # (Show p, Show r) => Show (Polygon t p r) Source # Instance detailsDefined in Data.Geometry.Polygon MethodsshowsPrec :: Int -> Polygon t p r -> ShowS #show :: Polygon t p r -> String #showList :: [Polygon t p r] -> ShowS # (NFData p, NFData r) => NFData (Polygon t p r) Source # Instance detailsDefined in Data.Geometry.Polygon Methodsrnf :: Polygon t p r -> () # Fractional r => IsTransformable (Polygon t p r) Source # Instance detailsDefined in Data.Geometry.Polygon MethodstransformBy :: Transformation (Dimension (Polygon t p r)) (NumType (Polygon t p r)) -> Polygon t p r -> Polygon t p r Source # IsBoxable (Polygon t p r) Source # Instance detailsDefined in Data.Geometry.Polygon MethodsboundingBox :: Polygon t p r -> Box (Dimension (Polygon t p r)) () (NumType (Polygon t p r)) Source # IpeWriteText r => IpeWriteText (Polygon t () r) Source # Instance detailsDefined in Data.Geometry.Ipe.Writer MethodsipeWriteText :: Polygon t () r -> Maybe Text Source # HasDefaultIpeOut (Polygon t p r) Source # Instance detailsDefined in Data.Geometry.Ipe.IpeOut Associated Typestype DefaultIpeOut (Polygon t p r) :: * -> * Source # MethodsdefaultIpeOut :: IpeOut (Polygon t p r) (IpeObject' (DefaultIpeOut (Polygon t p r)) (NumType (Polygon t p r))) Source # type NumType (SomePolygon p r) Source # Instance detailsDefined in Data.Geometry.Polygon type NumType (SomePolygon p r) = r type Dimension (SomePolygon p r) Source # Instance detailsDefined in Data.Geometry.Polygon type Dimension (SomePolygon p r) = 2 type DefaultFromIpe (MultiPolygon () r) Source # Instance detailsDefined in Data.Geometry.Ipe.FromIpe type DefaultFromIpe (MultiPolygon () r) = Path type DefaultFromIpe (SimplePolygon () r) Source # Instance detailsDefined in Data.Geometry.Ipe.FromIpe type DefaultFromIpe (SimplePolygon () r) = Path type DefaultIpeOut (SomePolygon p r) Source # Instance detailsDefined in Data.Geometry.Ipe.IpeOut type DefaultIpeOut (SomePolygon p r) = Path type IntersectionOf (Line 2 r) (Boundary (Polygon t p r)) Source # Instance detailsDefined in Data.Geometry.Polygon type IntersectionOf (Line 2 r) (Boundary (Polygon t p r)) = Seq (Either (Point 2 r) (LineSegment 2 () r)) ': ([] :: [*]) type NumType (Polygon t p r) Source # Instance detailsDefined in Data.Geometry.Polygon type NumType (Polygon t p r) = r type Dimension (Polygon t p r) Source # Instance detailsDefined in Data.Geometry.Polygon type Dimension (Polygon t p r) = 2 type DefaultIpeOut (Polygon t p r) Source # Instance detailsDefined in Data.Geometry.Ipe.IpeOut type DefaultIpeOut (Polygon t p r) = Path

We distinguish between simple polygons (without holes) and Polygons with holes.

Constructors

 Simple Multi

bitraverseVertices :: (Applicative f, Traversable t) => (p -> f q) -> (r -> f s) -> t (Point 2 r :+ p) -> f (t (Point 2 s :+ q)) Source #

outerBoundary :: forall t p r. Lens' (Polygon t p r) (CSeq (Point 2 r :+ p)) Source #

polygonHoles :: forall p r. Lens' (Polygon Multi p r) [Polygon Simple p r] Source #

outerVertex :: Int -> Lens' (Polygon t p r) (Point 2 r :+ p) Source #

Access the i^th vertex on the outer boundary

holeList :: Polygon t p r -> [Polygon Simple p r] Source #

Get all holes in a polygon

polygonVertices :: Polygon t p r -> NonEmpty (Point 2 r :+ p) Source #

The vertices in the polygon. No guarantees are given on the order in which they appear!

outerBoundaryEdges :: Polygon t p r -> CSeq (LineSegment 2 p r) Source #

The edges along the outer boundary of the polygon. The edges are half open.

running time: $$O(n)$$

listEdges :: Polygon t p r -> [LineSegment 2 p r] Source #

Lists all edges. The edges on the outer boundary are given before the ones on the holes. However, no other guarantees are given on the order.

running time: $$O(n)$$

withIncidentEdges :: Polygon t p r -> Polygon t (Two (LineSegment 2 p r)) r Source #

Pairs every vertex with its incident edges. The first one is its predecessor edge, the second one its successor edge.

>>> mapM_ print . polygonVertices \$ withIncidentEdges simplePoly
Point2 [0 % 1,0 % 1] :+ SP LineSegment (Closed (Point2 [1 % 1,11 % 1] :+ ())) (Closed (Point2 [0 % 1,0 % 1] :+ ())) LineSegment (Closed (Point2 [0 % 1,0 % 1] :+ ())) (Closed (Point2 [10 % 1,0 % 1] :+ ()))
Point2 [10 % 1,0 % 1] :+ SP LineSegment (Closed (Point2 [0 % 1,0 % 1] :+ ())) (Closed (Point2 [10 % 1,0 % 1] :+ ())) LineSegment (Closed (Point2 [10 % 1,0 % 1] :+ ())) (Closed (Point2 [10 % 1,10 % 1] :+ ()))
Point2 [10 % 1,10 % 1] :+ SP LineSegment (Closed (Point2 [10 % 1,0 % 1] :+ ())) (Closed (Point2 [10 % 1,10 % 1] :+ ())) LineSegment (Closed (Point2 [10 % 1,10 % 1] :+ ())) (Closed (Point2 [5 % 1,15 % 1] :+ ()))
Point2 [5 % 1,15 % 1] :+ SP LineSegment (Closed (Point2 [10 % 1,10 % 1] :+ ())) (Closed (Point2 [5 % 1,15 % 1] :+ ())) LineSegment (Closed (Point2 [5 % 1,15 % 1] :+ ())) (Closed (Point2 [1 % 1,11 % 1] :+ ()))
Point2 [1 % 1,11 % 1] :+ SP LineSegment (Closed (Point2 [5 % 1,15 % 1] :+ ())) (Closed (Point2 [1 % 1,11 % 1] :+ ())) LineSegment (Closed (Point2 [1 % 1,11 % 1] :+ ())) (Closed (Point2 [0 % 1,0 % 1] :+ ()))


toEdges :: CSeq (Point 2 r :+ p) -> CSeq (LineSegment 2 p r) Source #

Given the vertices of the polygon. Produce a list of edges. The edges are half-open.

onBoundary :: (Fractional r, Ord r) => Point 2 r -> Polygon t p r -> Bool Source #

Test if q lies on the boundary of the polygon. Running time: O(n)

>>> point2 1 1 onBoundary simplePoly
False
>>> point2 0 0 onBoundary simplePoly
True
>>> point2 10 0 onBoundary simplePoly
True
>>> point2 5 13 onBoundary simplePoly
False
>>> point2 5 10 onBoundary simplePoly
False
>>> point2 10 5 onBoundary simplePoly
True
>>> point2 20 5 onBoundary simplePoly
False


TODO: testcases multipolygon

inPolygon :: forall t p r. (Fractional r, Ord r) => Point 2 r -> Polygon t p r -> PointLocationResult Source #

Check if a point lies inside a polygon, on the boundary, or outside of the polygon. Running time: O(n).

>>> point2 1 1 inPolygon simplePoly
Inside
>>> point2 0 0 inPolygon simplePoly
OnBoundary
>>> point2 10 0 inPolygon simplePoly
OnBoundary
>>> point2 5 13 inPolygon simplePoly
Inside
>>> point2 5 10 inPolygon simplePoly
Inside
>>> point2 10 5 inPolygon simplePoly
OnBoundary
>>> point2 20 5 inPolygon simplePoly
Outside


TODO: Add some testcases with multiPolygons TODO: Add some more onBoundary testcases

insidePolygon :: (Fractional r, Ord r) => Point 2 r -> Polygon t p r -> Bool Source #

Test if a point lies strictly inside the polgyon.

area :: Fractional r => Polygon t p r -> r Source #

Compute the area of a polygon

signedArea :: Fractional r => SimplePolygon p r -> r Source #

Compute the signed area of a simple polygon. The the vertices are in clockwise order, the signed area will be negative, if the verices are given in counter clockwise order, the area will be positive.

centroid :: Fractional r => SimplePolygon p r -> Point 2 r Source #

Compute the centroid of a simple polygon.

isCounterClockwise :: (Eq r, Fractional r) => Polygon t p r -> Bool Source #

Test if the outer boundary of the polygon is in clockwise or counter clockwise order.

running time: $$O(n)$$

toClockwiseOrder :: (Eq r, Fractional r) => Polygon t p r -> Polygon t p r Source #

Orient the outer boundary to clockwise order

toCounterClockWiseOrder :: (Eq r, Fractional r) => Polygon t p r -> Polygon t p r Source #

Orient the outer boundary to counter clockwise order

asSimplePolygon :: Polygon t p r -> SimplePolygon p r Source #

Convert a Polygon to a simple polygon by forgetting about any holes.

cmpExtreme :: (Num r, Ord r) => Vector 2 r -> (Point 2 r :+ p) -> (Point 2 r :+ q) -> Ordering Source #

Comparison that compares which point is larger in the direction given by the vector u.

extremesLinear :: (Ord r, Num r) => Vector 2 r -> Polygon t p r -> (Point 2 r :+ p, Point 2 r :+ p) Source #

Finds the extreme points, minimum and maximum, in a given direction

running time: $$O(n)$$

numberVertices :: Polygon t p r -> Polygon t (SP Int p) r Source #

assigns unique integer numbers to all vertices. Numbers start from 0, and are increasing along the outer boundary. The vertices of holes will be numbered last, in the same order.

>>> numberVertices simplePoly
SimplePolygon CSeq [Point2 [0 % 1,0 % 1] :+ SP 0 (),Point2 [10 % 1,0 % 1] :+ SP 1 (),Point2 [10 % 1,10 % 1] :+ SP 2 (),Point2 [5 % 1,15 % 1] :+ SP 3 (),Point2 [1 % 1,11 % 1] :+ SP 4 ()]