user203212546 user203212546 - 6 months ago 32
Javascript Question

How can I use GLMatrix to do matrix multiplications?

I'm just beginning to try to find/use a matrix operations library for JS. I want to do simple translation, scale, and rotation operations on 2D matrices. The mozilla developer website recommends GLMatrix for its "focus on speed and performance."

I'm just wanting to do some simple 2D transformations on matrices, e.g. using

. I want to do something like this:

var a = mat2d.fromValues(2,0,2,0,0,0);
var b = mat2d.fromValues(1,3,3,1,-1,-2);
var ans = mat2d();


<script src=""></script>

but I must not have the syntax right because I get an
Uncaught TypeError: mat2d is not a function
(JSFiddle). I am using
found here.

How can I fix my matrix multiplication code snippet above?



var ans = mat2d.create();

to create a new (identity) matrix. See the docs or the source.