# mat4-decompose

> decomposes a 3D matrix

Latest version **1.0.4** (published 2015-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install mat4-decompose
pnpm add mat4-decompose
yarn add mat4-decompose
bun add mat4-decompose
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2015-02-08 |
| First published | 2014-12-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | 4x4, decompose, gl-mat4, mat4, decomposition, interpolation, lerp, linear, tween, animate, css, matrix |

## Links

- npm: https://www.npmjs.com/package/mat4-decompose
- Repository: https://github.com/mattdesl/mat4-decompose
- Issues: https://github.com/mattdesl/mat4-decompose/issues
- npm.io page: https://npm.io/package/mat4-decompose

## Dependencies (2)

- [gl-mat4](https://npm.io/package/gl-mat4.md) ^1.0.1
- [gl-vec3](https://npm.io/package/gl-vec3.md) ^1.0.2

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2015-02-08
- 1.0.3 — 2014-12-07
- 1.0.2 — 2014-12-07
- 1.0.1 — 2014-12-07
- 1.0.0 — 2014-12-07

## README

# mat4-decompose

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

Decomposes a 3D matrix, useful for animations. Code ported from [W3 CSS Spec](http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix). PRs for more tests/robustness/optimizations welcome. 

Order:

- first isolates perspective
- then determines translation
- then determines X scale, XY shear, Y scale, XZ and YZ shear, and Z scale
- then determines quaternion rotation

You may also be interested in [mat4-interpolate](https://www.npmjs.com/package/mat4-interpolate), [mat4-recompose](https://www.npmjs.com/package/mat4-recompose), and [css-mat4](https://www.npmjs.com/package/css-mat4).

## Usage

[![NPM](https://nodei.co/npm/mat4-decompose.png)](https://nodei.co/npm/mat4-decompose/)

#### `valid = decompose(matrix[, translation, scale, skew, perspective, quaternion])`

Decomposes the given `matrix` (an array of 16 floats, like those gl-matrix operates on), storing the results into the specified optional vectors.

- `translation` [x, y, z]
- `scale` [x, y, z]
- `skew` [xy, xz, yz] skew factors
- `perspective` [x, y, z, w]
- `quaternion` [x, y, z, w]

Returns `false` is this matrix cannot be decomposed, `true` otherwise.

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/mat4-decompose/blob/master/LICENSE.md) for details.

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