mat4.multiplyVec4 is wrong
Closed this issue · 3 comments
GoogleCodeExporter commented
dest[4] should be dest[3] in this method and mat[4] should be mat[3]
mat4.multiplyVec4 = function(mat, vec, dest) {
if(!dest) { dest = vec }
var x = vec[0], y = vec[1], z = vec[2], w = vec[3];
dest[0] = mat[0]*x + mat[4]*y + mat[8]*z + mat[12]*w;
dest[1] = mat[1]*x + mat[5]*y + mat[9]*z + mat[13]*w;
dest[2] = mat[2]*x + mat[6]*y + mat[10]*z + mat[14]*w;
/* Here is the error: dest[4] should be dest[3] and mat[4] should be mat[3]*/
dest[4] = mat[4]*x + mat[7]*y + mat[11]*z + mat[15]*w;
return dest;
};
Original issue reported on code.google.com by jeremyMl...@gmail.com
on 18 Dec 2010 at 4:46
GoogleCodeExporter commented
Thanks for catching that. Stupid mistake on my part.
Original comment by Tojiro@gmail.com
on 27 Feb 2011 at 4:41
- Changed state: Started
GoogleCodeExporter commented
Original comment by Tojiro@gmail.com
on 27 Feb 2011 at 6:18
- Changed state: Fixed
GoogleCodeExporter commented
I think it's wrong...
A matrix multiplicated by a vector is a line by col multiplication :
dest[0] = mat[0]*x + mat[1]*y + mat[2]*z + mat[3]*w;
dest[1] = mat[4]*x + mat[5]*y + mat[6]*z + mat[7]*w;
dest[2] = mat[8]*x + mat[9]*y + mat[10]*z + mat[11]*w;
dest[3] = mat[12]*x + mat[13]*y + mat[14]*z + mat[15]*w;
Original comment by jg.germ...@gmail.com
on 4 Aug 2011 at 8:50