This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decomposeMatrix(m) { | |
var t,r,s,k,E,F,G,H,Q,R,sx,sy,a1,a2,theta,phi,sqrt=Math.sqrt,atan2=Math.atan2; | |
// http://math.stackexchange.com/questions/861674/decompose-a-2d-arbitrary-transform-into-only-scaling-and-rotation | |
// | |
// It works wonderfully! Thanks. | |
// The input matrix is transposed though, | |
// so let me spell the solution out. | |
E=(m[0]+m[3])/2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* http://en.wikipedia.org/wiki/B%C3%A9zier_curve | |
* http://www.malczak.linuxpl.com/blog/quadratic-bezier-curve-length/g | |
*/ | |
function Point(x, y) { | |
this.x = x; | |
this.y = y; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var net = require('net'); | |
var util = require('util'); | |
var Writable = require('stream').Writable; | |
/** | |
* Pretends to consume the data written to it. In reality, it just eats data | |
* really slowly. | |
* | |
* @constructor | |
* @extends Writable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This code takes a 2D transformation matrix described as a one-dimensional array | |
(in column order, top to bottom and left to right) and decomposes it using the dojo | |
matrix library. This input matrix should produce a 45-deg X skew: | |
1 1 0 | |
0 1 0 | |
0 0 1 | |
The output of decompose() looks like this: |