-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Efficient geometric vectors and transformations. -- -- This Haskell library implements several small vectors types with -- Double fields, with seperate types for each size of vector, -- and a type class for handling vectors generally. Existing API has been -- rearranged. Now supports 4D vectors and linear transformations. @package AC-Vector @version 2.0.0 -- | General function applicable to all vector types. module Data.Vector.Class -- | The type of vector field values. type Scalar = Double -- | All vector types belong to this class. Aside from vpack and -- vunpack, these methods aren't especially useful to end-users; -- they're used internally by the vector arithmetic implementations. class Vector v vmap :: (Vector v) => (Scalar -> Scalar) -> (v -> v) vzip :: (Vector v) => (Scalar -> Scalar -> Scalar) -> (v -> v -> v) vfold :: (Vector v) => (Scalar -> Scalar -> Scalar) -> (v -> Scalar) vpack :: (Vector v) => [Scalar] -> Maybe v vunpack :: (Vector v) => v -> [Scalar] -- | Scale a vector (i.e., change its length but not its direction). This -- operator has the same precedence as the usual (*) operator. -- -- The (*|) and (|*) operators are identical, but with -- their argument flipped. Just remember that the '|' denotes -- the scalar part. (*|) :: (Vector v) => Scalar -> v -> v -- | Scale a vector (i.e., change its length but not its direction). This -- operator has the same precedence as the usual (*) operator. -- -- The (*|) and (|*) operators are identical, but with -- their argument flipped. Just remember that the '|' denotes -- the scalar part. (|*) :: (Vector v) => v -> Scalar -> v -- | Take the dot product of two vectors. This is a scalar equal to -- the cosine of the angle between the two vectors multiplied by the -- length of each vectors. vdot :: (Vector v) => v -> v -> Scalar -- | Return the length or magnitude of a vector. (Note that this -- involves a slow square root operation.) vmag :: (Vector v) => v -> Scalar -- | Normalise a vector. In order words, return a new vector with the same -- direction, but a length of exactly one. (If the vector's length is -- zero or very near to zero, the vector is returned unchanged.) vnormalise :: (Vector v) => v -> v -- | Linearly interpolate between two points in space. -- -- vlinear :: (Num v, Vector v) => Scalar -> v -> v -> v -- | 1-dimensional vectors with vector arithmetic. -- -- This isn't especially useful. Usually if you want to calculate with -- scalars, you can just use the Scalar type directly. However, -- this module provides a Vector1 newtype over Scalar that -- allows a scalar to be treated as a sort of vector, which is very -- occasionally useful. module Data.Vector.V1 -- | The type of 1D vectors. -- -- Owing to its particularly simple structure, this type has more class -- instances than 'propper' vectors have. Still, for the most part you'll -- probably want to just use Scalar itself directly. newtype Vector1 Vector1 :: Scalar -> Vector1 v1x :: Vector1 -> Scalar instance Eq Vector1 instance Ord Vector1 instance Enum Vector1 instance Show Vector1 instance Num Vector1 instance Fractional Vector1 instance Vector Vector1 -- | 2-dimensional vectors with vector arithmetic. module Data.Vector.V2 data Vector2 Vector2 :: !!Scalar -> !!Scalar -> Vector2 v2x :: Vector2 -> !!Scalar v2y :: Vector2 -> !!Scalar instance Eq Vector2 instance Show Vector2 instance Fractional Vector2 instance Num Vector2 instance Vector Vector2 -- | 3-dimensional vectors with vector arithmetic. module Data.Vector.V3 data Vector3 Vector3 :: !!Scalar -> !!Scalar -> !!Scalar -> Vector3 v3x :: Vector3 -> !!Scalar v3y :: Vector3 -> !!Scalar v3z :: Vector3 -> !!Scalar -- | Take the cross product of two 3D vectors. This produces a new -- 3D vector that is perpendicular to the plane of the first two vectors, -- and who's length is equal to the sine of the angle between those -- vectors multiplied by their lengths. -- -- Note that a `vcross` b = negate (b `vcross` a). vcross :: Vector3 -> Vector3 -> Vector3 instance Eq Vector3 instance Show Vector3 instance Fractional Vector3 instance Num Vector3 instance Vector Vector3 -- | 4-dimensional vectors with vector arithmetic. module Data.Vector.V4 data Vector4 Vector4 :: !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> Vector4 v4x :: Vector4 -> !!Scalar v4y :: Vector4 -> !!Scalar v4z :: Vector4 -> !!Scalar v4w :: Vector4 -> !!Scalar instance Eq Vector4 instance Show Vector4 instance Fractional Vector4 instance Num Vector4 instance Vector Vector4 -- | 1-dimensional linear transformations. module Data.Vector.Transform.T1 -- | The type of 1D linear transformations. Essentially, this is applying a -- linear function to a number. -- -- Note the Monoid instance, which gives you access to the -- identity transform (mempty) and the ability to combine a -- series of transforms into a single transform (mappend). data Transform1 Transform1 :: !!Scalar -> !!Scalar -> Transform1 t1_XX :: Transform1 -> !!Scalar t1_1X :: Transform1 -> !!Scalar -- | Apply a 1D transformation to a 1D point, yielding a new 1D point. transformP1 :: Transform1 -> Vector1 -> Vector1 instance Eq Transform1 instance Show Transform1 instance Monoid Transform1 -- | 2-dimensional linear transformations. module Data.Vector.Transform.T2 -- | The type of 2D linear transformations. -- -- Note the Monoid instance, which gives you access to the -- identity transform (mempty) and the ability to combine a -- series of transforms into a single transform (mappend). data Transform2 Transform2 :: !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> Transform2 t2_XX :: Transform2 -> !!Scalar t2_YX :: Transform2 -> !!Scalar t2_1X :: Transform2 -> !!Scalar t2_XY :: Transform2 -> !!Scalar t2_YY :: Transform2 -> !!Scalar t2_1Y :: Transform2 -> !!Scalar -- | Apply a 2D transformation to a 2D point, yielding a new 2D point. transformP2 :: Transform2 -> Vector2 -> Vector2 instance Eq Transform2 instance Show Transform2 instance Monoid Transform2 -- | 3-dimensional linear transformations. module Data.Vector.Transform.T3 -- | The type of 3D linear transformations. -- -- Note the Monoid instance, which gives you access to the -- identity transform (mempty) and the ability to combine a -- series of transforms into a single transform (mappend). data Transform3 Transform3 :: !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> Transform3 t3_XX :: Transform3 -> !!Scalar t3_YX :: Transform3 -> !!Scalar t3_ZX :: Transform3 -> !!Scalar t3_1X :: Transform3 -> !!Scalar t3_XY :: Transform3 -> !!Scalar t3_YY :: Transform3 -> !!Scalar t3_ZY :: Transform3 -> !!Scalar t3_1Y :: Transform3 -> !!Scalar t3_XZ :: Transform3 -> !!Scalar t3_YZ :: Transform3 -> !!Scalar t3_ZZ :: Transform3 -> !!Scalar t3_1Z :: Transform3 -> !!Scalar -- | Apply a 3D transformation to a 3D point, yielding a new 3D point. transformP3 :: Transform3 -> Vector3 -> Vector3 instance Eq Transform3 instance Show Transform3 instance Monoid Transform3 -- | 4-dimensional linear transformations. module Data.Vector.Transform.T4 -- | The type of 4D linear transformations. -- -- Note the Monoid instance, which gives you access to the -- identity transform (mempty) and the ability to combine a -- series of transforms into a single transform (mappend). data Transform4 Transform4 :: !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> Transform4 t4_XX :: Transform4 -> !!Scalar t4_YX :: Transform4 -> !!Scalar t4_ZX :: Transform4 -> !!Scalar t4_WX :: Transform4 -> !!Scalar t4_1X :: Transform4 -> !!Scalar t4_XY :: Transform4 -> !!Scalar t4_YY :: Transform4 -> !!Scalar t4_ZY :: Transform4 -> !!Scalar t4_WY :: Transform4 -> !!Scalar t4_1Y :: Transform4 -> !!Scalar t4_XZ :: Transform4 -> !!Scalar t4_YZ :: Transform4 -> !!Scalar t4_ZZ :: Transform4 -> !!Scalar t4_WZ :: Transform4 -> !!Scalar t4_1Z :: Transform4 -> !!Scalar t4_XW :: Transform4 -> !!Scalar t4_YW :: Transform4 -> !!Scalar t4_ZW :: Transform4 -> !!Scalar t4_WW :: Transform4 -> !!Scalar t4_1W :: Transform4 -> !!Scalar -- | Apply a 4D transformation to a 4D point, yielding a new 4D point. transformP4 :: Transform4 -> Vector4 -> Vector4 instance Eq Transform4 instance Show Transform4 instance Monoid Transform4 -- | Convenience module to import all sizes of transform. (This doesn't -- include all the field names though, just the transform types and their -- application functions.) module Data.Vector.Transform -- | The type of 1D linear transformations. Essentially, this is applying a -- linear function to a number. -- -- Note the Monoid instance, which gives you access to the -- identity transform (mempty) and the ability to combine a -- series of transforms into a single transform (mappend). data Transform1 -- | Apply a 1D transformation to a 1D point, yielding a new 1D point. transformP1 :: Transform1 -> Vector1 -> Vector1 -- | The type of 2D linear transformations. -- -- Note the Monoid instance, which gives you access to the -- identity transform (mempty) and the ability to combine a -- series of transforms into a single transform (mappend). data Transform2 -- | Apply a 2D transformation to a 2D point, yielding a new 2D point. transformP2 :: Transform2 -> Vector2 -> Vector2 -- | The type of 3D linear transformations. -- -- Note the Monoid instance, which gives you access to the -- identity transform (mempty) and the ability to combine a -- series of transforms into a single transform (mappend). data Transform3 -- | Apply a 3D transformation to a 3D point, yielding a new 3D point. transformP3 :: Transform3 -> Vector3 -> Vector3 -- | The type of 4D linear transformations. -- -- Note the Monoid instance, which gives you access to the -- identity transform (mempty) and the ability to combine a -- series of transforms into a single transform (mappend). data Transform4 -- | Apply a 4D transformation to a 4D point, yielding a new 4D point. transformP4 :: Transform4 -> Vector4 -> Vector4 -- | Convenience module providing easy access to everything in this -- package. (See individual modules for fuller details.) module Data.Vector