Matrix Transformer
The Matrix Transformer is a small composable library of functions that can be used to easily manipulate x,y,z coordinates in 3D space.
The Concept
Manipulated 3D coordinates is ultimately a series of mathematical operations on the original coordinates. These operations can be combined easily using matrix multiplication. By using the functions in this library one can transformations can be treated as a pipeline, where the data moves through the chained together functions and comes out the other side in with the correct scale, rotation, and translation.
Getting Started
npm install matrix_transformer
Once installed import the Matrix
constructor
Using es2015
:
import Matrix from 'matrix_transformer';
Using pre es2015
:
var Matrix = require('matrix_transformer');
Usage
Initialize a new instance of a Matrix
module passing in an object with starting x, y, z coordinates:
let coords = new Matrix({x: 1, y: 2, z: 3});
Manipulating Individual Axes
The lowest level of manipulations can be performed on each individual axis for all three translation, scale and rotation

Translate Axis (
translateX, translateY, translateZ
) takes an offset value which will be added to the coordinate 
Scale Axis (
scaleX, scaleY, scaleZ
) takes a scalar value which will be multiplied by that coordinate 
Rotate Axis (`rotateX, rotateY, rotateZ takes a degree of rotation and applies it to that coordate. Positive rotation is always in the counter clockwise direction.
NOTE: order of operations MATTERS!
Example of individual axis manipulation:
let result = coords.translateX(10).scaleY(2).rotateZ(90);
console.log(result.toObject()) // output > {x: 4, y: 11, z: 3}