Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- module Data.Geometry.Vector.VectorFamily
- module Linear.Vector
- data C (n :: Nat) = C
- class Additive (Diff p) => Affine (p :: * -> *) where
- qdA :: (Affine p, Foldable (Diff p), Num a) => p a -> p a -> a
- distanceA :: (Floating a, Foldable (Diff p), Affine p) => p a -> p a -> a
- dot :: (Metric f, Num a) => f a -> f a -> a
- norm :: (Metric f, Floating a) => f a -> a
- signorm :: (Metric f, Floating a) => f a -> f a
- isScalarMultipleOf :: (Eq r, Fractional r, Arity d) => Vector d r -> Vector d r -> Bool
- scalarMultiple :: (Eq r, Fractional r, Arity d) => Vector d r -> Vector d r -> Maybe r
- replicate :: Vector v a => a -> v a
- imap :: (Vector v a, Vector v b) => (Int -> a -> b) -> v a -> v b
Documentation
module Linear.Vector
A proxy which can be used for the coordinates.
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@
(.-.) :: 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
qdA :: (Affine p, Foldable (Diff p), Num a) => p a -> p a -> a #
Compute the quadrance of the difference (the square of the distance)
distanceA :: (Floating a, Foldable (Diff p), Affine p) => p a -> p a -> a #
Distance between two points in an affine space
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
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)
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"]