-- 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. Now includes -- "bounding box" types, useful for graphical work. (Note that this -- package itself has no graphics facilities as such. It just provides -- data structures useful for graphics.) @package AC-Vector @version 2.1.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 -- | This module provides the Range type and several functions for -- working with ranges. module Data.BoundingBox.Range -- | A Range represents a continuous interval between two -- Scalar endpoints. data Range Range :: !!Scalar -> !!Scalar -> Range min_bound :: Range -> !!Scalar max_bound :: Range -> !!Scalar -- | Given two Scalars, construct a Range (swapping the -- endpoints if necessary so that they are in the correct order. bounds :: Scalar -> Scalar -> Range -- | Test whether a given Scalar falls within a particular -- Range. within_bounds :: Scalar -> Range -> Bool -- | Take the union of two ranges. The resulting Range contains all -- points that the original ranges contained, plus any points between -- them (if the original ranges don't overlap). union :: Range -> Range -> Range -- | Take the intersection of two ranges. If the ranges do not overlap, the -- intersection is empty, and Nothing is returned. (This is a good -- way to check whether two ranges overlap or not.) Otherwise a new -- Range is returned that contains only the points common to both -- ranges. isect :: Range -> Range -> Maybe Range instance Eq Range instance Show Range -- | This module provides the BBox1 type (mainly for completeness). module Data.BoundingBox.B1 -- | The BBox1 type is basically a Range, but all the -- operations over it work with Vector1 (which is really -- Scalar). While it's called a bounding box, a -- 1-dimensional box is in truth a simple line interval, just like -- Range. newtype BBox1 BBox1 :: Range -> BBox1 range :: BBox1 -> Range -- | Given two vectors, construct a bounding box (swapping the endpoints if -- necessary). bounds :: Vector1 -> Vector1 -> BBox1 -- | Test whether a Vector1 lies within a BBox1. within_bounds :: Vector1 -> BBox1 -> Bool -- | Return the minimum endpoint for a BBox1. min_bound :: BBox1 -> Vector1 -- | Return the maximum endpoint for a BBox1. max_bound :: BBox1 -> Vector1 -- | Take the union of two BBox1 values. The result is a new -- BBox1 that contains all the points the original boxes -- contained, plus any extra space between them. union :: BBox1 -> BBox1 -> BBox1 -- | Take the intersection of two BBox1 values. If the boxes do not -- overlap, return Nothing. Otherwise return a BBox1 -- containing only the points common to both argument boxes. isect :: BBox1 -> BBox1 -> Maybe BBox1 instance Eq BBox1 instance Show BBox1 -- | This module provides the BBox2 type for 2-dimensional bounding -- boxes. module Data.BoundingBox.B2 -- | A BBox2 is a 2D bounding box (aligned to the coordinate axies). data BBox2 BBox2 :: !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> BBox2 minX :: BBox2 -> !!Scalar minY :: BBox2 -> !!Scalar maxX :: BBox2 -> !!Scalar maxY :: BBox2 -> !!Scalar -- | Return the X-range that this bounding box covers. rangeX :: BBox2 -> Range -- | Return the Y-range that this bounding box covers. rangeY :: BBox2 -> Range -- | Given ranges for each coordinate axis, construct a bounding box. rangeXY :: Range -> Range -> BBox2 -- | Given a pair of corner points, construct a bounding box. (The points -- must be from opposite corners, but it doesn't matter which -- corners nor which order they are given in.) bounds :: Vector2 -> Vector2 -> BBox2 -- | Test whether a given 2D vector is inside this bounding box. within_bounds :: Vector2 -> BBox2 -> Bool -- | Return the minimum values for both coordinates. (In usual 2D space, -- the bottom-left corner point.) min_bound :: BBox2 -> Vector2 -- | Return the maximum values for both coordinates. (In usual 2D space, -- the top-right corner point.) max_bound :: BBox2 -> Vector2 -- | Take the union of two bounding boxes. The result is a new bounding box -- that contains all the points the original boxes contained, plus any -- extra space between them. union :: BBox2 -> BBox2 -> BBox2 -- | Take the intersection of two bounding boxes. If the boxes do not -- overlap, return Nothing. Otherwise return a new bounding box -- containing only the points common to both argument boxes. isect :: BBox2 -> BBox2 -> Maybe BBox2 instance Eq BBox2 instance Show BBox2 -- | This module provides the BBox3 type for 3-dimensional bounding -- boxes ("bounding volumes"). module Data.BoundingBox.B3 -- | A BBox3 is a 3D bounding box (aligned to the coordinate axies). data BBox3 BBox3 :: !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> BBox3 minX :: BBox3 -> !!Scalar minY :: BBox3 -> !!Scalar minZ :: BBox3 -> !!Scalar maxX :: BBox3 -> !!Scalar maxY :: BBox3 -> !!Scalar maxZ :: BBox3 -> !!Scalar -- | Return the X-range that this bounding box covers. rangeX :: BBox3 -> Range -- | Return the Y-range that this bounding box covers. rangeY :: BBox3 -> Range -- | Return the Z-range that this bounding box covers. rangeZ :: BBox3 -> Range -- | Given ranges for each coordinate axis, construct a bounding box. rangeXYZ :: Range -> Range -> Range -> BBox3 -- | Given a pair of corner points, construct a bounding box. (The points -- must be from opposite corners, but it doesn't matter which -- corners nor which order they are given in.) bounds :: Vector3 -> Vector3 -> BBox3 -- | Test whether a given 3D vector is inside this bounding box. within_bounds :: Vector3 -> BBox3 -> Bool -- | Return the minimum values for all coordinates. min_bound :: BBox3 -> Vector3 -- | Return the maximum values for all coordinates. max_bound :: BBox3 -> Vector3 -- | Take the union of two bounding boxes. The result is a new bounding box -- that contains all the points the original boxes contained, plus any -- extra space between them. union :: BBox3 -> BBox3 -> BBox3 -- | Take the intersection of two bounding boxes. If the boxes do not -- overlap, return Nothing. Otherwise return a new bounding box -- containing only the points common to both argument boxes. isect :: BBox3 -> BBox3 -> Maybe BBox3 instance Eq BBox3 instance Show BBox3 -- | This module provides the BBox4 type for 4-dimensional bounding -- boxes (bounding hyper-volumes). module Data.BoundingBox.B4 -- | A BBox4 is a 4D bounding box (aligned to the coordinate axies). data BBox4 BBox4 :: !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> !!Scalar -> BBox4 minX :: BBox4 -> !!Scalar minY :: BBox4 -> !!Scalar minZ :: BBox4 -> !!Scalar minW :: BBox4 -> !!Scalar maxX :: BBox4 -> !!Scalar maxY :: BBox4 -> !!Scalar maxZ :: BBox4 -> !!Scalar maxW :: BBox4 -> !!Scalar -- | Return the X-range that this bounding box covers. rangeX :: BBox4 -> Range -- | Return the Y-range that this bounding box covers. rangeY :: BBox4 -> Range -- | Return the Z-range that this bounding box covers. rangeZ :: BBox4 -> Range -- | Return the W-range (4th coordinate) that this bounding box covers. rangeW :: BBox4 -> Range -- | Given ranges for each coordinate axis, construct a bounding box. rangeXYZW :: Range -> Range -> Range -> Range -> BBox4 -- | Given a pair of corner points, construct a bounding box. (The points -- must be from opposite corners, but it doesn't matter which -- corners nor which order they are given in.) bounds :: Vector4 -> Vector4 -> BBox4 -- | Test whether a given 4D vector is inside this bounding box. within_bounds :: Vector4 -> BBox4 -> Bool -- | Return the minimum values for all coordinates. min_bound :: BBox4 -> Vector4 -- | Return the maximum values for all coordinates. max_bound :: BBox4 -> Vector4 -- | Take the union of two bounding boxes. The result is a new bounding box -- that contains all the points the original boxes contained, plus any -- extra space between them. union :: BBox4 -> BBox4 -> BBox4 -- | Take the intersection of two bounding boxes. If the boxes do not -- overlap, return Nothing. Otherwise return a new bounding box -- containing only the points common to both argument boxes. isect :: BBox4 -> BBox4 -> Maybe BBox4 instance Eq BBox4 instance Show BBox4 -- | Convenience module providing easy access to everything in this -- package. (See individual modules for fuller details.) module Data.Vector