matrix_transformer
Functional library to perform chained matrix transformations on 3D x,y,z coordinates
Last updated 4 years ago by ckeyes88 .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install matrix_transformer 
SYNC missed versions from official npm registry.

Matrix Transformer

Build Status

The Matrix Transformer is a small composable library of functions that can be used to easily manipulate x,y,z coordinates in 3-D space.

The Concept

Manipulated 3-D 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} 

Current Tags

  • 0.0.8                                ...           latest (4 years ago)

8 Versions

  • 0.0.8                                ...           4 years ago
  • 0.0.7                                ...           4 years ago
  • 0.0.6                                ...           4 years ago
  • 0.0.5                                ...           4 years ago
  • 0.0.4                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (0)
None
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |