Module

# Data.Vector

Package
purescript-vector
Repository
jutaro/purescript-vector

### #VecSource

``newtype Vec s a``

#### Constructors

• `Vec (Array a)`

#### Instances

• `(Eq a) => Eq (Vec s a)`
• `(Show a) => Show (Vec s a)`
• `Functor (Vec s)`
• `Apply (Vec s)`
• `Foldable (Vec s)`
• `(Sized s) => Semiring (Vec s Number)`

### #fillSource

``fill :: forall a s. EuclideanRing a => Sized s => a -> Vec s a``

### #fromArraySource

``fromArray :: forall a s. Sized s => Array a -> Vec s a``

### #toArraySource

``toArray :: forall a s. Vec s a -> Array a``

``vAdd :: forall s a. EuclideanRing a => Vec s a -> Vec s a -> Vec s a``

### #vSubSource

``vSub :: forall s a. EuclideanRing a => Vec s a -> Vec s a -> Vec s a``

### #vMulSource

``vMul :: forall s a. EuclideanRing a => Vec s a -> Vec s a -> Vec s a``

### #vNegateSource

``vNegate :: forall s a. EuclideanRing a => Vec s a -> Vec s a``

### #directionSource

``direction :: forall s. Vec s Number -> Vec s Number -> Vec s Number``

The normalized direction from a to b: (a - b) / |a - b|

### #vlengthSquaredSource

``vlengthSquared :: forall s. Vec s Number -> Number``

The length of the given vector: |a|

### #vlengthSource

``vlength :: forall s. Vec s Number -> Number``

The length of the given vector: |a|

### #normalizeSource

``normalize :: forall s. Vec s Number -> Vec s Number``

A unit vector with the same direction as the given vector: a / |a|

### #distanceSquaredSource

``distanceSquared :: forall s. Vec s Number -> Vec s Number -> Number``

The distance between two vectors.

### #distanceSource

``distance :: forall s. Vec s Number -> Vec s Number -> Number``

The distance between two vectors.

### #scaleSource

``scale :: forall s a. EuclideanRing a => a -> Vec s a -> Vec s a``

Multiply the vector by a scalar: s * v

### #dotSource

``dot :: forall s. Vec s Number -> Vec s Number -> Number``

The dot product of a and b