# gl-vec4

> gl-matrix's vec4, split into smaller pieces

Latest version **1.0.1** (published 2015-05-14) · Zlib license · 0 weekly downloads

## Install

```sh
npm install gl-vec4
pnpm add gl-vec4
yarn add gl-vec4
bun add gl-vec4
```

## Health

**Score 18/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-05-14 |
| First published | 2015-05-14 |
| Weekly downloads | 0 |
| License | Zlib |
| TypeScript types | separate (@types/gl-vec4) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Maintainers | mattdesl, hughsk, mikolalysenko |
| Keywords | ecosystem:stackgl, gl-matrix, matrix, math, gl, mat4, mat4x4, 4x4, vectors, vec4, color, mat, vector, maths |

## Links

- npm: https://www.npmjs.com/package/gl-vec4
- Repository: https://github.com/stackgl/gl-vec4
- Issues: https://github.com/stackgl/gl-vec4/issues
- npm.io page: https://npm.io/package/gl-vec4

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2015-05-14
- 1.0.0 — 2015-05-14

## README

# gl-vec4

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Part of a fork of [@toji](http://github.com/toji)'s
[gl-matrix](http://github.com/toji/gl-matrix) split into smaller pieces: this
package contains `glMatrix.vec4`.

## Usage

[![NPM](https://nodei.co/npm/gl-vec4.png)](https://nodei.co/npm/gl-vec4/)

### `vec4 = require('gl-vec4')`

Will load all of the module's functionality and expose it on a single
object. Note that any of the methods may also be required directly
from their files.

For example, the following are equivalent:

``` javascript
var scale = require('gl-vec4').scale
var scale = require('gl-vec4/scale')
```

## API

  - [add()](#addoutvec4-avec4-bvec4)
  - [clone()](#cloneavec4)
  - [copy()](#copyoutvec4-avec4)
  - [create()](#create)
  - [distance()](#distanceavec4-bvec4)
  - [divide()](#divideoutvec4-avec4-bvec4)
  - [dot()](#dotavec4-bvec4)
  - [fromValues()](#fromvaluesxnumber-ynumber-znumber-wnumber)
  - [inverse()](#inverseoutvec4-avec4)
  - [length()](#lengthavec4)
  - [lerp()](#lerpoutvec4-avec4-bvec4-tnumber)
  - [max()](#maxoutvec4-avec4-bvec4)
  - [min()](#minoutvec4-avec4-bvec4)
  - [multiply()](#multiplyoutvec4-avec4-bvec4)
  - [negate()](#negateoutvec4-avec4)
  - [normalize()](#normalizeoutvec4-avec4)
  - [random()](#randomoutvec4-scalenumber)
  - [scale()](#scaleoutvec4-avec4-bnumber)
  - [scaleAndAdd()](#scaleandaddoutvec4-avec4-bvec4-scalenumber)
  - [set()](#setoutvec4-xnumber-ynumber-znumber-wnumber)
  - [squaredDistance()](#squareddistanceavec4-bvec4)
  - [squaredLength()](#squaredlengthavec4)
  - [subtract()](#subtractoutvec4-avec4-bvec4)
  - [transformMat4()](#transformmat4outvec4-avec4-mmat4)
  - [transformQuat()](#transformquatoutvec4-avec4-qquat)

## add(out:vec4, a:vec4, b:vec4)

  Adds two vec4's

## clone(a:vec4)

  Creates a new vec4 initialized with values from an existing vector

## copy(out:vec4, a:vec4)

  Copy the values from one vec4 to another

## create()

  Creates a new, empty vec4

## distance(a:vec4, b:vec4)

  Calculates the euclidian distance between two vec4's

## divide(out:vec4, a:vec4, b:vec4)

  Divides two vec4's

## dot(a:vec4, b:vec4)

  Calculates the dot product of two vec4's

## fromValues(x:Number, y:Number, z:Number, w:Number)

  Creates a new vec4 initialized with the given values

## inverse(out:vec4, a:vec4)

  Returns the inverse of the components of a vec4

## length(a:vec4)

  Calculates the length of a vec4

## lerp(out:vec4, a:vec4, b:vec4, t:Number)

  Performs a linear interpolation between two vec4's

## max(out:vec4, a:vec4, b:vec4)

  Returns the maximum of two vec4's

## min(out:vec4, a:vec4, b:vec4)

  Returns the minimum of two vec4's

## multiply(out:vec4, a:vec4, b:vec4)

  Multiplies two vec4's

## negate(out:vec4, a:vec4)

  Negates the components of a vec4

## normalize(out:vec4, a:vec4)

  Normalize a vec4

## random(out:vec4, [scale]:Number)

  Generates a random vector with the given scale

## scale(out:vec4, a:vec4, b:Number)

  Scales a vec4 by a scalar number

## scaleAndAdd(out:vec4, a:vec4, b:vec4, scale:Number)

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

## set(out:vec4, x:Number, y:Number, z:Number, w:Number)

  Set the components of a vec4 to the given values

## squaredDistance(a:vec4, b:vec4)

  Calculates the squared euclidian distance between two vec4's

## squaredLength(a:vec4)

  Calculates the squared length of a vec4

## subtract(out:vec4, a:vec4, b:vec4)

  Subtracts vector b from vector a

## transformMat4(out:vec4, a:vec4, m:mat4)

  Transforms the vec4 with a mat4.

## transformQuat(out:vec4, a:vec4, q:quat)

  Transforms the vec4 with a quat

## License

MIT. See [LICENSE.md](http://github.com/stackgl/gl-vec4/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/gl-vec4 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
