-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Efficient geometric vectors.
--
-- 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. Changes: * Operator
-- *<> has been renamed |* (and there's a matching
-- *| operator now too). * There is now a vnormalise
-- function.
@package AC-Vector
@version 1.2.1
-- | This module provides several small vectors over Double
-- values. All fields are strict and unpacked, so using these should be
-- fairly efficient. Each size of vector is a seperate type. It also
-- provides a few vector constants to save you some typing now and then.
module Data.Vector
-- | The type of Vector fields.
type Scalar = Double
-- | The Vector class. All vectors are members of this class, and
-- it provides ways to apply functions over vectors. Typically this
-- methods aren't used directly; rather, the other class instances for
-- each vector are implemented in terms of these.
class Vector v
fromScalar :: (Vector v) => Scalar -> 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
-- | Takes the dot product of two vectors [of the same dimension].
-- If you remember your highschool linear algebra, the dot product of two
-- vectors V and W is equal to |V| * |W| * cos k, where |V| is the length
-- of vector V, and k is the minimum angle between the two vectors.
vdot :: (Vector v) => v -> v -> Scalar
-- | Returns the magnitude of a vector (that is, it's length). Note
-- that this is always positive or zero (never negative).
vmag :: (Vector v) => v -> Scalar
-- | Multiply a vector by a scalar. This scales the magnitude (length) of
-- the vector, but leaves its length unchanged. (Except in the case of a
-- negative scalar, in which case the vector's direction is reversed.)
--
-- The operators |* and *| are identical, just with their
-- arguments flipped.
(|*) :: (Vector v) => Scalar -> v -> v
-- | Multiply a vector by a scalar. This scales the magnitude (length) of
-- the vector, but leaves its length unchanged. (Except in the case of a
-- negative scalar, in which case the vector's direction is reversed.)
--
-- The operators *| and |* are identical, just with their
-- arguments flipped.
(*|) :: (Vector v) => v -> Scalar -> v
-- | Adjust a vector so that its length is exactly one. (Or, if the
-- vector's length was zero, it stays zero.)
vnormalise :: (Vector v) => v -> v
-- | The type of 2-dimensional vectors. It provides various class instances
-- such as Eq, Num, Show, etc.
data Vector2
Vector2 :: !!Scalar -> !!Scalar -> Vector2
v2x :: Vector2 -> !!Scalar
v2y :: Vector2 -> !!Scalar
-- | Constant: The unit-length X vector, (1, 0).
vector2X :: Vector2
-- | Constant: The unit-length Y vector, (0, 1).
vector2Y :: Vector2
-- | The type of 3-dimensional vectors. Similar to Vector2.
data Vector3
Vector3 :: !!Scalar -> !!Scalar -> !!Scalar -> Vector3
v3x :: Vector3 -> !!Scalar
v3y :: Vector3 -> !!Scalar
v3z :: Vector3 -> !!Scalar
-- | Takes the cross product of two [3D] vectors. Again, from
-- highschool linear algebra, the cross product of vector V and W is a
-- new vector P such that |P| = |V| * |W| * sin k (where k is the minimum
-- angle between V and W), and the direction of P is perpendicular to
-- both V and W. For example, vcross vector3X vector3Y
-- = vector3Z. Note also that vcross w v = negate (vcross
-- v w).
vcross :: Vector3 -> Vector3 -> Vector3
-- | Constant: The unit-length X vector, (1, 0, 0).
vector3X :: Vector3
-- | Constant: The unit-length Y vector, (0, 1, 0).
vector3Y :: Vector3
-- | Constant: The unit-length Z vector, (0, 0, 1).
vector3Z :: Vector3
instance Eq Vector3
instance Ord Vector3
instance Show Vector3
instance Eq Vector2
instance Ord Vector2
instance Show Vector2
instance Fractional Vector3
instance Num Vector3
instance Vector Vector3
instance Fractional Vector2
instance Num Vector2
instance Vector Vector2