• Stars
    star
    360
  • Rank 118,230 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Javascript isomorphic 2D affine transformations written in ES6 syntax. Manipulate transformation matrices with this totally tested library!

transformation-matrix

Javascript isomorphic 2D affine transformations written in ES6 syntax. Manipulate transformation matrices with this totally tested library!

chrvadala Test Coverage Status npm Downloads Donate

Features

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:

  • generate transformation matrices for the following operations: translation, rotation, scale, shear, skew
  • merge multiple transformation matrices in a single matrix that is the composition of multiple matrices
  • work with strings in both directions: parse, render
  • apply a transformation matrix to point(s)
  • decompose a matrix into translation, scaling and rotation components, with flip decomposition support

Documentation

Install

npm install transformation-matrix

or

<script src="https://unpkg.com/transformation-matrix@2"></script>

Example

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 ]

Changelog

  • 0.0 - Preview version
  • 1.0 - First public version
  • 1.1 - Splits lib into different files
  • 1.2 - Adds shear operation
  • 1.3 - Adds umd support
  • 1.4 - Adds typescript definitions
  • 1.5 - Upgrades deps
  • 1.6 - Adds optional parameter support on translate(tx), scale(sx), rotate(angle, cx, cy)
  • 1.7 - Upgrades deps
  • 1.8 - Fixes #12, Adds fromTransformAttribute, Discontinues node 4 support
  • 1.9 - Adds skew(ax, ay), Upgrades deps, Improves fromTransformAttribute
  • 1.10- Updates typescript definitions #15
  • 1.11- Upgrades deps
  • 1.12- Migrates tests on Jest, Integrates standard.js, Upgrades deps
  • 1.13- Adds compose function, Upgrades deps, Exposes skew operation #37
  • 1.14- Adds support for points defined as Array in the form [x, y] #38
  • 1.15- Adds fromTriangle and smoothMatrix functions #41
  • 2.0- Migrates to Babel 7 and updates dependencies; introduces fromDefinition function; breaking changes on fromTransformAttribute function; improves docs
  • 2.1- Upgrades deps; Adds Node.js v12 to CI
  • 2.2- Upgrades deps; Improves typescript definition #66
  • 2.3- Adds (cx,cy) on scale function #62; Improves typescript definition #66; Upgrades deps
  • 2.4- Improves typescript definition #75
  • 2.5- Upgrades deps; Deprecates NodeJS 8; Adds NodeJs 14 support
  • 2.6- Upgrades deps; Fixes fromTransformAttribute function #84
  • 2.7- Upgrades deps;
  • 2.8- Upgrades deps;
  • 2.9- Adds flipX(), flipY(), flipOrigin() functions; Deprecates NodeJS 12 and adds NodeJS 16 support; Upgrades deps;
  • 2.10 - Adds decomposeTSR() function #88; Upgrades deps;
  • 2.11 - Migrates from yarn to npm; Upgrades deps; New APIs documentation; Integrates chrvadala/github-actions;
  • 2.12 - Migrates from PEG.js to Peggy #89; Upgrades deps;
  • 2.13 - Upgrades deps; Improves typescript definition; Upgrades gh-actions deps;
  • 2.14 - Upgrades deps; Adds fromOneMovingPoint and fromTwoMovingPoints functions #95
  • 2.15 - Removes circular dependencies #97; Upgrades gh-actions and deps

Contributors

Some projects using transformation-matrix

More Repositories

1

react-svg-pan-zoom

👀 A React component that adds pan and zoom features to SVG
JavaScript
677
star
2

node-ble

Bluetooth Low Energy (BLE) library written with pure Node.js (no bindings) - baked by Bluez via DBus
JavaScript
308
star
3

music-beat-detector

music-beat-detector is a library that analyzes a music stream and detects any beat. It can be used to control lights or any magic effect by the music wave.
JavaScript
254
star
4

awesome-protocols

Curated list of awesome technology protocols with a reference to official RFCs
28
star
5

create-music-stream

Creates a PCM 16 bit Little Endian Stream from a mp3 file or youtube video
JavaScript
24
star
6

potree-converter-docker

Potree Converter utility packed as Docker Container
Dockerfile
19
star
7

react-refactor

🔧 Convert your React Class Component to Functional Component and vice-versa
JavaScript
16
star
8

neopixel

Node.js library to control Adafruit NeoPixel based on ws2812 led family
C++
15
star
9

docker-compose-examples

💻 This project intends to collect common docker-compose use cases. Each example can be used as a boilerplate.
PHP
13
star
10

kafka-test-helper

Utility library that simplify testing of Node.js components that interacts with Kafka broker.
JavaScript
8
star
11

weather-station

Connector able to download weather data from an Oregon Scientific EMR211X station, leveraging on Bluetooth Low Energy connection
JavaScript
6
star
12

mqtt-dispatcher

MQTT dispatcher is a library that extends MQTT.js and allows to route incoming messages on a specific handler, according to defined routing rules.
JavaScript
6
star
13

biconnected-components

Find biconnected component in a graph using algorithm by John Hopcroft and Robert Tarjan
JavaScript
3
star
14

aggregate-fn

Aggregate fn is a tiny Javascript utility that groups together multiple async operations.
JavaScript
3
star
15

const-version

✨ A tiny command line tool that extract `package.json` version and generate `export const VERSION='...'` file. Useful when you want to package your software version.
JavaScript
3
star
16

tableauSolver

Prolog algorithm that applies the method of analytic tableaux and creates a graphical representation of a propositional tableau
Prolog
2
star
17

github-actions

Github actions that automates some common scenarios.
2
star
18

react-redux-boilerplate

😋 A suggested React + Redux projects structure.
JavaScript
2
star
19

aws-cloud-stacks

AWS CloudFormation stacks that speed-up projects development.
Shell
2
star
20

cisco-decrypt-docker

🙈 Docker container with Decoder for password encoding of Cisco VPN client
C
2
star
21

chrvadala.github.io

Hello, this is Christian Vadalà's website. Here you can find a list of open source projects, backed by React, Node.JS and AWS technologies.
JavaScript
1
star
22

react-stylerify

A browserify wrapper around react-styling
JavaScript
1
star
23

sudoku.go

🎲 Sudoku solver written in golang
Go
1
star
24

sliding-window-max

Given a stream of data, this algorithm returns (for every added value) the current max value.
JavaScript
1
star
25

setup-my-pc

setup-my-pc.sh is a simple script that configures personal computers, virtual machines and servers with some common tools. It fastify the setup of a new development environment.
Shell
1
star