Javascript isomorphic 2D affine transformations written in ES6 syntax. Manipulate transformation matrices with this totally tested library!
Javascript isomorphic 2D affine transformations written in ES6 syntax. Manipulate transformation matrices with this totally tested library!
Transformations, i.e. linear invertible automorphisms, are used to map a picture into another one with different size, position and orientation. Given a basis, transformations are represented by means of squared invertible matrices, called transformation matrices.
A geometric transformation is defined as a one-to-one mapping of a point space to itself, which preservers some geometric relations of figures. - Geometric Programming for Computer Aided Design
This library allows us to:
Basic Operations
Calculate
Validate
Apply
Stringify
Compose
Decompose
Moving points (gestures)
npm install transformation-matrix
or
<script src="https://unpkg.com/transformation-matrix@2"></script>
import {scale, rotate, translate, compose, applyToPoint} from 'transformation-matrix';
let {scale, rotate, translate, compose, applyToPoint} = window.TransformationMatrix;
let {scale, rotate, translate, compose, applyToPoint} = require('transformation-matrix')
let matrix = compose(
translate(40,40),
rotate(Math.PI/2),
scale(2, 4)
);
applyToPoint(matrix, {x: 42, y: 42});
// { x: -128, y: 124.00000000000001 }
applyToPoint(matrix, [16, 24]);
// [ -56, 72 ]
translate(tx)
, scale(sx)
, rotate(angle, cx, cy)
fromTransformAttribute
, Discontinues node 4 supportskew(ax, ay)
, Upgrades deps, Improves fromTransformAttribute
compose
function, Upgrades deps, Exposes skew operation #37Array
in the form [x, y]
#38fromTriangle
and smoothMatrix
functions #41fromDefinition
function; breaking changes on fromTransformAttribute
function; improves docs(cx,cy)
on scale
function #62; Improves typescript definition #66; Upgrades depsflipX()
, flipY()
, flipOrigin()
functions; Deprecates NodeJS 12 and adds NodeJS 16 support; Upgrades deps; decomposeTSR()
function #88; Upgrades deps;fromOneMovingPoint
and fromTwoMovingPoints
functions #95