# Module: vec3

3 Dimensional Vector

Source:
  - vec3.js, line 3

### Methods

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

Adds two vec3's

##### Parameters:

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

Source:
  - vec3.js, line 104

##### Returns:

out

Type
  vec3

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

Get the angle between two 3D vectors

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | vec3 | The first operand
`b` | vec3 | The second operand

Source:
  - vec3.js, line 633

##### Returns:

The angle in radians

Type
  Number

#### (static) bezier(out, a, b, c, d, t) → {vec3}

Performs a bezier interpolation with two control points

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | the receiving vector
`a` | vec3 | the first operand
`b` | vec3 | the second operand
`c` | vec3 | the third operand
`d` | vec3 | the fourth operand
`t` | Number | interpolation amount, in the range [0-1], between the two inputs

Source:
  - vec3.js, line 434

##### Returns:

out

Type
  vec3

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

Math.ceil the components of a vec3

##### Parameters:

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

Source:
  - vec3.js, line 163

##### Returns:

out

Type
  vec3

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

Creates a new vec3 initialized with values from an existing vector

##### Parameters:

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

Source:
  - vec3.js, line 29

##### Returns:

a new 3D vector

Type
  vec3

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

Copy the values from one vec3 to another

##### Parameters:

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

Source:
  - vec3.js, line 73

##### Returns:

out

Type
  vec3

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

Creates a new, empty vec3

Source:
  - vec3.js, line 13

##### Returns:

a new 3D vector

Type
  vec3

#### (static) cross(out, a, b) → {vec3}

Computes the cross product of two vec3's

##### Parameters:

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

Source:
  - vec3.js, line 369

##### Returns:

out

Type
  vec3

#### (static) dist()

Alias for vec3.distance

Source:
  - vec3.js, line 710

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

Calculates the euclidian distance between two vec3's

##### Parameters:

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

Source:
  - vec3.js, line 266

##### Returns:

distance between a and b

Type
  Number

#### (static) div()

Alias for vec3.divide

Source:
  - vec3.js, line 704

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

Divides two vec3's

##### Parameters:

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

Source:
  - vec3.js, line 149

##### Returns:

out

Type
  vec3

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

Calculates the dot product of two vec3's

##### Parameters:

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

Source:
  - vec3.js, line 357

##### 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` | vec3 | The first vector.
`b` | vec3 | The second vector.

Source:
  - vec3.js, line 680

##### 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` | vec3 | The first vector.
`b` | vec3 | The second vector.

Source:
  - vec3.js, line 669

##### Returns:

True if the vectors are equal, false otherwise.

Type
  Boolean

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

Math.floor the components of a vec3

##### Parameters:

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

Source:
  - vec3.js, line 177

##### Returns:

out

Type
  vec3

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

Perform some operation over an array of vec3s.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`a` | Array |  | the array of vectors to iterate over
`stride` | Number |  | Number of elements between the start of each vec3. If 0 assumes tightly packed
`offset` | Number |  | Number of elements to skip at the beginning of the array
`count` | Number |  | Number of vec3s 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:
  - vec3.js, line 742

##### Returns:

a

Type
  Array

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

Creates a new vec3 initialized with the given values

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | Number | X component
`y` | Number | Y component
`z` | Number | Z component

Source:
  - vec3.js, line 58

##### Returns:

a new 3D vector

Type
  vec3

#### (static) hermite(out, a, b, c, d, t) → {vec3}

Performs a hermite interpolation with two control points

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | the receiving vector
`a` | vec3 | the first operand
`b` | vec3 | the second operand
`c` | vec3 | the third operand
`d` | vec3 | the fourth operand
`t` | Number | interpolation amount, in the range [0-1], between the two inputs

Source:
  - vec3.js, line 409

##### Returns:

out

Type
  vec3

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

Returns the inverse of the components of a vec3

##### Parameters:

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

Source:
  - vec3.js, line 321

##### Returns:

out

Type
  vec3

#### (static) len()

Alias for vec3.length

Source:
  - vec3.js, line 722

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

Calculates the length of a vec3

##### Parameters:

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

Source:
  - vec3.js, line 43

##### Returns:

length of a

Type
  Number

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

Performs a linear interpolation between two vec3's

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | the receiving vector
`a` | vec3 | the first operand
`b` | vec3 | the second operand
`t` | Number | interpolation amount, in the range [0-1], between the two inputs

Source:
  - vec3.js, line 388

##### Returns:

out

Type
  vec3

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

Returns the maximum of two vec3's

##### Parameters:

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

Source:
  - vec3.js, line 207

##### Returns:

out

Type
  vec3

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

Returns the minimum of two vec3's

##### Parameters:

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

Source:
  - vec3.js, line 192

##### Returns:

out

Type
  vec3

#### (static) mul()

Alias for vec3.multiply

Source:
  - vec3.js, line 698

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

Multiplies two vec3's

##### Parameters:

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

Source:
  - vec3.js, line 134

##### Returns:

out

Type
  vec3

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

Negates the components of a vec3

##### Parameters:

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

Source:
  - vec3.js, line 307

##### Returns:

out

Type
  vec3

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

Normalize a vec3

##### Parameters:

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

Source:
  - vec3.js, line 335

##### Returns:

out

Type
  vec3

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

Generates a random vector with the given scale

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`out` | vec3 |  | the receiving vector
`scale` | Number | <optional> | Length of the resulting vector. If ommitted, a unit vector will be returned

Source:
  - vec3.js, line 457

##### Returns:

out

Type
  vec3

#### (static) rotateX(out, a, b, c) → {vec3}

Rotate a 3D vector around the x-axis

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | The receiving vec3
`a` | vec3 | The vec3 point to rotate
`b` | vec3 | The origin of the rotation
`c` | Number | The angle of rotation

Source:
  - vec3.js, line 551

##### Returns:

out

Type
  vec3

#### (static) rotateY(out, a, b, c) → {vec3}

Rotate a 3D vector around the y-axis

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | The receiving vec3
`a` | vec3 | The vec3 point to rotate
`b` | vec3 | The origin of the rotation
`c` | Number | The angle of rotation

Source:
  - vec3.js, line 579

##### Returns:

out

Type
  vec3

#### (static) rotateZ(out, a, b, c) → {vec3}

Rotate a 3D vector around the z-axis

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | The receiving vec3
`a` | vec3 | The vec3 point to rotate
`b` | vec3 | The origin of the rotation
`c` | Number | The angle of rotation

Source:
  - vec3.js, line 607

##### Returns:

out

Type
  vec3

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

Math.round the components of a vec3

##### Parameters:

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

Source:
  - vec3.js, line 221

##### Returns:

out

Type
  vec3

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

Scales a vec3 by a scalar number

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | the receiving vector
`a` | vec3 | the vector to scale
`b` | Number | amount to scale the vector by

Source:
  - vec3.js, line 236

##### Returns:

out

Type
  vec3

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

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

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | the receiving vector
`a` | vec3 | the first operand
`b` | vec3 | the second operand
`scale` | Number | the amount to scale b by before adding

Source:
  - vec3.js, line 252

##### Returns:

out

Type
  vec3

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

Set the components of a vec3 to the given values

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | the receiving vector
`x` | Number | X component
`y` | Number | Y component
`z` | Number | Z component

Source:
  - vec3.js, line 89

##### Returns:

out

Type
  vec3

#### (static) sqrDist()

Alias for vec3.squaredDistance

Source:
  - vec3.js, line 716

#### (static) sqrLen()

Alias for vec3.squaredLength

Source:
  - vec3.js, line 728

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

Calculates the squared euclidian distance between two vec3's

##### Parameters:

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

Source:
  - vec3.js, line 280

##### Returns:

squared distance between a and b

Type
  Number

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

Calculates the squared length of a vec3

##### Parameters:

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

Source:
  - vec3.js, line 293

##### Returns:

squared length of a

Type
  Number

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

Returns a string representation of a vector

##### Parameters:

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

Source:
  - vec3.js, line 658

##### Returns:

string representation of the vector

Type
  String

#### (static) sub()

Alias for vec3.subtract

Source:
  - vec3.js, line 692

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

Subtracts vector b from vector a

##### Parameters:

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

Source:
  - vec3.js, line 119

##### Returns:

out

Type
  vec3

#### (static) transformMat3(out, a, m) → {vec3}

Transforms the vec3 with a mat3.

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | the receiving vector
`a` | vec3 | the vector to transform
`m` | mat3 | the 3x3 matrix to transform with

Source:
  - vec3.js, line 497

##### Returns:

out

Type
  vec3

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

Transforms the vec3 with a mat4. 4th vector component is implicitly '1'

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | the receiving vector
`a` | vec3 | the vector to transform
`m` | mat4 | matrix to transform with

Source:
  - vec3.js, line 479

##### Returns:

out

Type
  vec3

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

Transforms the vec3 with a quat Can also be used for dual quaternions. (Multiply it with the real part)

##### Parameters:

Name | Type | Description
--- | --- | ---
`out` | vec3 | the receiving vector
`a` | vec3 | the vector to transform
`q` | quat | quaternion to transform with

Source:
  - vec3.js, line 514

##### Returns:

out

Type
  vec3