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

Data.Geometry.Vector.VectorFamily

Description

Implementation of $$d$$-dimensional vectors. The implementation automatically selects an optimized representation for small (up to size 4) vectors.

Synopsis

d dimensional Vectors

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

unV :: Lens (Vector d r) (Vector d s) (VectorFamily (Peano d) r) (VectorFamily (Peano d) s) Source #

class (ImplicitArity (Peano d), KnownNat d) => Arity d Source #

Instances
 (ImplicitArity (Peano d), KnownNat d) => Arity d Source # Instance detailsDefined in Data.Geometry.Vector.VectorFamily

Convenience "constructors"

pattern Vector :: VectorFamilyF (Peano d) r -> Vector d r Source #

pattern Vector1 :: r -> Vector 1 r Source #

pattern Vector2 :: r -> r -> Vector 2 r Source #

pattern Vector3 :: r -> r -> r -> Vector 3 r Source #

pattern Vector4 :: r -> r -> r -> r -> Vector 4 r 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 #

head :: (Arity d, 1 <= d) => Vector d r -> r Source #

Indexing vectors

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

Snoccing and consindg

cons :: (Arity d, Arity (d + 1)) => r -> Vector d r -> Vector (d + 1) r Source #

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.

last :: forall d r. (KnownNat d, Arity (d + 1)) => Vector (d + 1) r -> r Source #

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

Specific on 3-dimensional vectors

cross :: Num r => Vector 3 r -> Vector 3 r -> Vector 3 r Source #

Cross product of two three-dimensional vectors