0
votes

I'm trying to understand the rotation of the matrices using WebGL.

I got this mat4() matrix and I have to apply these transformations :

m = translate(torsoHeight+1*headHeight, 5, 0.0); 
m = mult(m, rotate(theta[head1Id], 1, 0, 0))
m = mult(m, rotate(theta[head2Id], 0, 1, 0));
m = mult(m, translate(0.0, -0.5*headHeight, 0.0));
figure[headId] = createNode( m, head, leftUpperArmId, null);
break;

I did not understand exactly how the mult function works. The first parameter is my matrix. The theta[] is built in this way :

var theta = [0, 0, 0, 0, 0, 0, 180, 0, 180, 0, 0];

and

var headId  = 1;
var head1Id = 1;
var head2Id = 10;

Am I right if I thought that the second parameter is another matrix build with the rotate() function ? In this case how does the rotate function work ?

1
I'd recommend these articles. The ones before explain rotation, the ones after expand to 3D. - gman

1 Answers

0
votes

rotate and translate are functions that create matrices.

rotate looks like it's arguments are (angle, vectorx, vectory, vectorz) to create a matrix rotating points around the given vectory.

mult is the standard mathematical multiplication for 4x4 matrices.

You probably should dig in linear algebra tutorials such as https://open.gl/transformations