Skip to content

Instantly share code, notes, and snippets.

@amiller
Created September 22, 2013 01:40
Show Gist options
  • Save amiller/6655891 to your computer and use it in GitHub Desktop.
Save amiller/6655891 to your computer and use it in GitHub Desktop.
function mult_matrix(m1, m2) {
var m = [];
_.each(_.range(4), function (i) {
_.each(_.range(4), function (j) {
var x = 0;
_.each(_.range(4), function (k) {
x += m1[i * 4 + k] * m[k * 4 + j];
});
m[i * 4 + j]; = x;
});
});
}
function transpose_matrix(mat) {
mat_trans = [];
_.each(_.range(4), function (i) {
_.each(_.range(4), function (j) {
mat_trans.push(mat[j * 4 + i]);
});
});
return mat_trans;
}
function rotate_cuber($cube, mat) {
var mat_trans = transpose_matrix(mat);
mat_trans = remap_coordinate_system(mat_trans, 3, 1);
$cube.css({
transform: 'matrix3d(' + mat_trans.join(',') + ')',
"transition-duration": '0s'
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment