# vec4

## vec4

4 Dimensional Vector

## Constructor

Source:

### Methods

#### #(static) add(out, a, b) → {vec4}

Source:

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the first operand

`b` vec4

the second operand

out

Type
vec4

#### #(static) clone(a) → {vec4}

Source:

Creates a new vec4 initialized with values from an existing vector

##### Parameters:
Name Type Description
`a` vec4

vector to clone

a new 4D vector

Type
vec4

#### #(static) copy(out, a) → {vec4}

Source:

Copy the values from one vec4 to another

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the source vector

out

Type
vec4

#### #(static) create() → {vec4}

Source:

Creates a new, empty vec4

a new 4D vector

Type
vec4

#### #(static) dist()

Source:

Alias for vec4.distance

#### #(static) distance(a, b) → {Number}

Source:

Calculates the euclidian distance between two vec4's

##### Parameters:
Name Type Description
`a` vec4

the first operand

`b` vec4

the second operand

##### Returns:

distance between a and b

Type
Number

#### #(static) div()

Source:

Alias for vec4.divide

#### #(static) divide(out, a, b) → {vec4}

Source:

Divides two vec4's

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the first operand

`b` vec4

the second operand

out

Type
vec4

#### #(static) dot(a, b) → {Number}

Source:

Calculates the dot product of two vec4's

##### Parameters:
Name Type Description
`a` vec4

the first operand

`b` vec4

the second operand

##### Returns:

dot product of a and b

Type
Number

#### #(static) forEach(a, stride, offset, count, fn, argopt) → {Array}

Source:

Perform some operation over an array of vec4s.

##### Parameters:
Name Type Attributes Description
`a` Array

the array of vectors to iterate over

`stride` Number

Number of elements between the start of each vec4. If 0 assumes tightly packed

`offset` Number

Number of elements to skip at the beginning of the array

`count` Number

Number of vec4s to iterate over. If 0 iterates over entire array

`fn` function

Function to call for each vector in the array

`arg` Object <optional>

additional argument to pass to fn

a

Type
Array

#### #(static) fromValues(x, y, z, w) → {vec4}

Source:

Creates a new vec4 initialized with the given values

##### Parameters:
Name Type Description
`x` Number

X component

`y` Number

Y component

`z` Number

Z component

`w` Number

W component

a new 4D vector

Type
vec4

#### #(static) inverse(out, a) → {vec4}

Source:

Returns the inverse of the components of a vec4

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

vector to invert

out

Type
vec4

#### #(static) len()

Source:

Alias for vec4.length

#### #(static) length(a) → {Number}

Source:

Calculates the length of a vec4

##### Parameters:
Name Type Description
`a` vec4

vector to calculate length of

length of a

Type
Number

#### #(static) lerp(out, a, b, t) → {vec4}

Source:

Performs a linear interpolation between two vec4's

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the first operand

`b` vec4

the second operand

`t` Number

interpolation amount between the two inputs

out

Type
vec4

#### #(static) max(out, a, b) → {vec4}

Source:

Returns the maximum of two vec4's

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the first operand

`b` vec4

the second operand

out

Type
vec4

#### #(static) min(out, a, b) → {vec4}

Source:

Returns the minimum of two vec4's

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the first operand

`b` vec4

the second operand

out

Type
vec4

#### #(static) mul()

Source:

Alias for vec4.multiply

#### #(static) multiply(out, a, b) → {vec4}

Source:

Multiplies two vec4's

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the first operand

`b` vec4

the second operand

out

Type
vec4

#### #(static) negate(out, a) → {vec4}

Source:

Negates the components of a vec4

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

vector to negate

out

Type
vec4

#### #(static) normalize(out, a) → {vec4}

Source:

Normalize a vec4

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

vector to normalize

out

Type
vec4

#### #(static) random(out, scaleopt) → {vec4}

Source:

Generates a random vector with the given scale

##### Parameters:
Name Type Attributes Description
`out` vec4

the receiving vector

`scale` Number <optional>

Length of the resulting vector. If ommitted, a unit vector will be returned

out

Type
vec4

#### #(static) scale(out, a, b) → {vec4}

Source:

Scales a vec4 by a scalar number

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the vector to scale

`b` Number

amount to scale the vector by

out

Type
vec4

#### #(static) scaleAndAdd(out, a, b, scale) → {vec4}

Source:

Adds two vec4's after scaling the second operand by a scalar value

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the first operand

`b` vec4

the second operand

`scale` Number

the amount to scale b by before adding

out

Type
vec4

#### #(static) set(out, x, y, z, w) → {vec4}

Source:

Set the components of a vec4 to the given values

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`x` Number

X component

`y` Number

Y component

`z` Number

Z component

`w` Number

W component

out

Type
vec4

Source:

#### #(static) sqrLen()

Source:

Alias for vec4.squaredLength

#### #(static) squaredDistance(a, b) → {Number}

Source:

Calculates the squared euclidian distance between two vec4's

##### Parameters:
Name Type Description
`a` vec4

the first operand

`b` vec4

the second operand

##### Returns:

squared distance between a and b

Type
Number

#### #(static) squaredLength(a) → {Number}

Source:

Calculates the squared length of a vec4

##### Parameters:
Name Type Description
`a` vec4

vector to calculate squared length of

##### Returns:

squared length of a

Type
Number

#### #(static) sub()

Source:

Alias for vec4.subtract

#### #(static) subtract(out, a, b) → {vec4}

Source:

Subtracts vector b from vector a

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the first operand

`b` vec4

the second operand

out

Type
vec4

#### #(static) transformMat4(out, a, m) → {vec4}

Source:

Transforms the vec4 with a mat4.

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the vector to transform

`m` mat4

matrix to transform with

out

Type
vec4

#### #(static) transformQuat(out, a, q) → {vec4}

Source:

Transforms the vec4 with a quat

##### Parameters:
Name Type Description
`out` vec4

the receiving vector

`a` vec4

the vector to transform

`q` quat

quaternion to transform with

out

Type
vec4