| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Geomancy.Vector
Synopsis
- class VectorSpace v a | v -> a where
- zeroVector :: v
- (*^) :: a -> v -> v
- (^/) :: v -> a -> v
- (^+^) :: v -> v -> v
- (^-^) :: v -> v -> v
- negateVector :: v -> v
- dot :: v -> v -> a
- norm :: v -> a
- normalize :: v -> v
- (^*) :: VectorSpace v a => v -> a -> v
- quadrance :: VectorSpace v a => v -> a
- lerp :: (VectorSpace v a, Num a) => v -> v -> a -> v
- lerpClip :: (VectorSpace v a, Ord a, Num a) => v -> v -> a -> v
Documentation
class VectorSpace v a | v -> a where #
Vector space type relation.
A vector space is a set (type) closed under addition and multiplication by
a scalar. The type of the scalar is the field of the vector space, and
it is said that v is a vector space over a.
The encoding uses a type class |VectorSpace| v a, where v represents
the type of the vectors and a represents the types of the scalars.
Minimal complete definition
zeroVector, (*^), (^+^), dot
Methods
zeroVector :: v #
Vector with no magnitude (unit for addition).
(*^) :: a -> v -> v infixr 9 #
Multiplication by a scalar.
(^/) :: v -> a -> v infixl 9 #
Division by a scalar.
(^+^) :: v -> v -> v infixl 6 #
Vector addition
(^-^) :: v -> v -> v infixl 6 #
Vector subtraction
negateVector :: v -> v #
Vector negation. Addition with a negated vector should be same as subtraction.
Dot product (also known as scalar or inner product).
For two vectors, mathematically represented as a = a1,a2,...,an and b
= b1,b2,...,bn, the dot product is a . b = a1*b1 + a2*b2 + ... +
an*bn.
Some properties are derived from this. The dot product of a vector with
itself is the square of its magnitude (norm), and the dot product of
two orthogonal vectors is zero.
Vector's norm (also known as magnitude).
For a vector represented mathematically as a = a1,a2,...,an, the norm
is the square root of a1^2 + a2^2 + ... + an^2.
Return a vector with the same origin and orientation (angle), but such that the norm is one (the unit for multiplication by a scalar).
Instances
| VectorSpace Vec2 Float Source # | |
| VectorSpace Packed Float Source # | |
Defined in Geomancy.Vec3 | |
| VectorSpace Vec3 Float Source # | |
| VectorSpace Vec4 Float Source # | |
| VectorSpace Double Double | |
| VectorSpace Float Float | |
Defined in Data.VectorSpace | |
| (Eq a, Floating a) => VectorSpace (a, a) a | Vector space instance for pairs of |
Defined in Data.VectorSpace | |
| (Eq a, Floating a) => VectorSpace (a, a, a) a | Vector space instance for triplets of |
Defined in Data.VectorSpace | |
| (Eq a, Floating a) => VectorSpace (a, a, a, a) a | Vector space instance for tuples with four |
Defined in Data.VectorSpace Methods zeroVector :: (a, a, a, a) # (*^) :: a -> (a, a, a, a) -> (a, a, a, a) # (^/) :: (a, a, a, a) -> a -> (a, a, a, a) # (^+^) :: (a, a, a, a) -> (a, a, a, a) -> (a, a, a, a) # (^-^) :: (a, a, a, a) -> (a, a, a, a) -> (a, a, a, a) # negateVector :: (a, a, a, a) -> (a, a, a, a) # | |
| (Eq a, Floating a) => VectorSpace (a, a, a, a, a) a | Vector space instance for tuples with five |
Defined in Data.VectorSpace Methods zeroVector :: (a, a, a, a, a) # (*^) :: a -> (a, a, a, a, a) -> (a, a, a, a, a) # (^/) :: (a, a, a, a, a) -> a -> (a, a, a, a, a) # (^+^) :: (a, a, a, a, a) -> (a, a, a, a, a) -> (a, a, a, a, a) # (^-^) :: (a, a, a, a, a) -> (a, a, a, a, a) -> (a, a, a, a, a) # negateVector :: (a, a, a, a, a) -> (a, a, a, a, a) # dot :: (a, a, a, a, a) -> (a, a, a, a, a) -> a # | |
(^*) :: VectorSpace v a => v -> a -> v Source #
quadrance :: VectorSpace v a => v -> a Source #
lerp :: (VectorSpace v a, Num a) => v -> v -> a -> v Source #