JSDoc: Module: vec4

# Module: vec4

4 Dimensional Vector

Source:
  - vec4.js, line 3

### Methods

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

Adds two vec4's

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec4 | the receiving vector
`a` | vec4 | the first operand
`b` | vec4 | the second operand

Source:
  - vec4.js, line 98

##### Returns:

out

Type
  vec4

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

Math.ceil the components of a vec4

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec4 | the receiving vector
`a` | vec4 | vector to ceil

Source:
  - vec4.js, line 161

##### Returns:

out

Type
  vec4

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

Creates a new vec4 initialized with values from an existing vector

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | vec4 | vector to clone

Source:
  - vec4.js, line 30

##### Returns:

a new 4D vector

Type
  vec4

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

Copy the values from one vec4 to another

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec4 | the receiving vector
`a` | vec4 | the source vector

Source:
  - vec4.js, line 64

##### Returns:

out

Type
  vec4

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

Creates a new, empty vec4

Source:
  - vec4.js, line 13

##### Returns:

a new 4D vector

Type
  vec4

#### (static) dist()

Alias for vec4.distance

Source:
  - vec4.js, line 543

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

Calculates the euclidian distance between two vec4's

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | vec4 | the first operand
`b` | vec4 | the second operand

Source:
  - vec4.js, line 271

##### Returns:

distance between a and b

Type
  Number

#### (static) div()

Alias for vec4.divide

Source:
  - vec4.js, line 537

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

Divides two vec4's

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec4 | the receiving vector
`a` | vec4 | the first operand
`b` | vec4 | the second operand

Source:
  - vec4.js, line 146

##### Returns:

out

Type
  vec4

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

Calculates the dot product of two vec4's

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | vec4 | the first operand
`b` | vec4 | the second operand

Source:
  - vec4.js, line 382

##### Returns:

dot product of a and b

Type
  Number

#### (static) equals(a, b) → {Boolean}

Returns whether or not the vectors have approximately the same elements in the same position.

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | vec4 | The first vector.
`b` | vec4 | The second vector.

Source:
  - vec4.js, line 512

##### Returns:

True if the vectors are equal, false otherwise.

Type
  Boolean

#### (static) exactEquals(a, b) → {Boolean}

Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | vec4 | The first vector.
`b` | vec4 | The second vector.

Source:
  - vec4.js, line 501

##### Returns:

True if the vectors are equal, false otherwise.

Type
  Boolean

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

Math.floor the components of a vec4

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec4 | the receiving vector
`a` | vec4 | vector to floor

Source:
  - vec4.js, line 176

##### Returns:

out

Type
  vec4

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

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

Source:
  - vec4.js, line 575

##### Returns:

a

Type
  Array

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

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

Source:
  - vec4.js, line 48

##### Returns:

a new 4D vector

Type
  vec4

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

Returns the inverse of the components of a vec4

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec4 | the receiving vector
`a` | vec4 | vector to invert

Source:
  - vec4.js, line 344

##### Returns:

out

Type
  vec4

#### (static) len()

Alias for vec4.length

Source:
  - vec4.js, line 555

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

Calculates the length of a vec4

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | vec4 | vector to calculate length of

Source:
  - vec4.js, line 300

##### Returns:

length of a

Type
  Number

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

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, in the range [0-1], between the two inputs

Source:
  - vec4.js, line 395

##### Returns:

out

Type
  vec4

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

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

Source:
  - vec4.js, line 208

##### Returns:

out

Type
  vec4

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

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

Source:
  - vec4.js, line 192

##### Returns:

out

Type
  vec4

#### (static) mul()

Alias for vec4.multiply

Source:
  - vec4.js, line 531

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

Multiplies two vec4's

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec4 | the receiving vector
`a` | vec4 | the first operand
`b` | vec4 | the second operand

Source:
  - vec4.js, line 130

##### Returns:

out

Type
  vec4

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

Negates the components of a vec4

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec4 | the receiving vector
`a` | vec4 | vector to negate

Source:
  - vec4.js, line 329

##### Returns:

out

Type
  vec4

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

Normalize a vec4

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec4 | the receiving vector
`a` | vec4 | vector to normalize

Source:
  - vec4.js, line 359

##### Returns:

out

Type
  vec4

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

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

Source:
  - vec4.js, line 414

##### Returns:

out

Type
  vec4

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

Math.round the components of a vec4

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec4 | the receiving vector
`a` | vec4 | vector to round

Source:
  - vec4.js, line 223

##### Returns:

out

Type
  vec4

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

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

Source:
  - vec4.js, line 239

##### Returns:

out

Type
  vec4

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

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

Source:
  - vec4.js, line 256

##### Returns:

out

Type
  vec4

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

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

Source:
  - vec4.js, line 82

##### Returns:

out

Type
  vec4

#### (static) sqrDist()

Alias for vec4.squaredDistance

Source:
  - vec4.js, line 549

#### (static) sqrLen()

Alias for vec4.squaredLength

Source:
  - vec4.js, line 561

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

Calculates the squared euclidian distance between two vec4's

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | vec4 | the first operand
`b` | vec4 | the second operand

Source:
  - vec4.js, line 286

##### Returns:

squared distance between a and b

Type
  Number

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

Calculates the squared length of a vec4

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | vec4 | vector to calculate squared length of

Source:
  - vec4.js, line 314

##### Returns:

squared length of a

Type
  Number

#### (static) str(a) → {String}

Returns a string representation of a vector

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | vec4 | vector to represent as a string

Source:
  - vec4.js, line 490

##### Returns:

string representation of the vector

Type
  String

#### (static) sub()

Alias for vec4.subtract

Source:
  - vec4.js, line 525

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

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

Source:
  - vec4.js, line 114

##### Returns:

out

Type
  vec4

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

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

Source:
  - vec4.js, line 449

##### Returns:

out

Type
  vec4

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

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

Source:
  - vec4.js, line 466

##### Returns:

out

Type
  vec4