hgeometry-0.12.0.0: Geometric Algorithms, Data structures, and Data types.
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageHaskell2010

Data.Geometry.Vector.VectorFixed

Description

 
Synopsis

Documentation

data C (n :: Nat) Source #

A proxy which can be used for the coordinates.

Constructors

C 

Instances

Instances details
Eq (C n) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Methods

(==) :: C n -> C n -> Bool #

(/=) :: C n -> C n -> Bool #

Ord (C n) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Methods

compare :: 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 details

Defined in Data.Geometry.Vector.VectorFixed

Methods

readsPrec :: Int -> ReadS (C n) #

readList :: ReadS [C n] #

readPrec :: ReadPrec (C n) #

readListPrec :: ReadPrec [C n] #

Show (C n) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Methods

showsPrec :: Int -> C n -> ShowS #

show :: C n -> String #

showList :: [C n] -> ShowS #

d dimensional Vectors

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

Datatype representing d dimensional vectors. Our implementation wraps the implementation provided by fixed-vector.

Constructors

Vector 

Fields

Instances

Instances details
Arity d => Functor (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Methods

fmap :: (a -> b) -> Vector d a -> Vector d b #

(<$) :: a -> Vector d b -> Vector d a #

Arity d => Applicative (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Methods

pure :: 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 details

Defined in Data.Geometry.Vector.VectorFixed

Methods

fold :: Monoid m => Vector d m -> m #

foldMap :: Monoid m => (a -> m) -> Vector d a -> 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 details

Defined in Data.Geometry.Vector.VectorFixed

Methods

traverse :: 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 => Eq1 (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Methods

liftEq :: (a -> b -> Bool) -> Vector d a -> Vector d b -> Bool #

Arity d => Affine (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Associated Types

type Diff (Vector d) :: Type -> Type #

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 details

Defined in Data.Geometry.Vector.VectorFixed

Methods

dot :: 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 details

Defined in Data.Geometry.Vector.VectorFixed

Methods

zero :: 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 details

Defined in Data.Geometry.Vector.VectorFixed

Methods

construct :: 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 details

Defined in Data.Geometry.Vector.VectorFixed

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 details

Defined in Data.Geometry.Vector.VectorFixed

Methods

compare :: 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 #

(Show r, Arity d) => Show (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Methods

showsPrec :: Int -> Vector d r -> ShowS #

show :: Vector d r -> String #

showList :: [Vector d r] -> ShowS #

Generic (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Associated Types

type Rep (Vector d r) :: Type -> Type #

Methods

from :: Vector d r -> Rep (Vector d r) x #

to :: Rep (Vector d r) x -> Vector d r #

(ToJSON r, Arity d) => ToJSON (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Methods

toJSON :: Vector d r -> Value #

toEncoding :: Vector d r -> Encoding #

toJSONList :: [Vector d r] -> Value #

toEncodingList :: [Vector d r] -> Encoding #

(FromJSON r, Arity d, KnownNat d) => FromJSON (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Methods

parseJSON :: Value -> Parser (Vector d r) #

parseJSONList :: Value -> Parser [Vector d r] #

(Arity d, NFData r) => NFData (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

Methods

rnf :: Vector d r -> () #

type Dim (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

type Dim (Vector d) = d
type Diff (Vector d) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

type Diff (Vector d) = Vector d
type Rep (Vector d r) Source # 
Instance details

Defined in Data.Geometry.Vector.VectorFixed

type Rep (Vector d r) = D1 ('MetaData "Vector" "Data.Geometry.Vector.VectorFixed" "hgeometry-0.12.0.0-3A6BqD11e4bE4Mwo2IplDZ" 'True) (C1 ('MetaCons "Vector" 'PrefixI 'True) (S1 ('MetaSel ('Just "_unV") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Vec d r))))

unV :: Lens' (Vector d r) (Vec d r) Source #

element :: forall proxy i d r. (Arity d, Arity 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

vectorFromList :: Arity d => [a] -> Maybe (Vector d a) Source #

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

Get the head and tail of a vector

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

Cross product of two three-dimensional vectors

toV2 :: Vector 2 a -> V2 a Source #

Vonversion to a Linear.V2

toV3 :: Vector 3 a -> V3 a Source #

Conversion to a Linear.V3

fromV3 :: V3 a -> Vector 3 a Source #

Conversion from a Linear.V3

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. (Arity 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

Functions specific to two and three dimensional vectors.

v2 :: r -> r -> Vector 2 r Source #

Construct a 2 dimensional vector

v3 :: r -> r -> r -> Vector 3 r Source #

Construct a 3 dimensional vector

_unV2 :: Vector 2 r -> (r, r) Source #

Destruct a 2 dim vector into a pair

_unV3 :: Vector 3 r -> (r, r, r) Source #

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

Pattern synonym for two and three dim vectors

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

pattern Vector4 :: r -> r -> r -> r -> Vector 4 r Source #