You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems like mat3.inverse() in version 2.4.0 actually computes the transpose of the inverse. mat4.inverse() is OK. I was trying to use gpu-matrix to compute a normal vector transformation matrix -- a mat3.normalMatrixFromMat4() function would be a good addition.
<script src="wgpu-matrix.js"></script>
<script>
let matrix = wgpuMatrix.mat3.create( 1,0,0, 0,1,0, 2,3,1 );
console.log( wgpuMatrix.mat3.multiply( matrix, wgpuMatrix.mat3.inverse(matrix) ) );
// does not output the identity matrix
console.log( wgpuMatrix.mat3.multiply( matrix, wgpuMatrix.mat3.transpose(wgpuMatrix.mat3.inverse(matrix)) ) );
// outputs the identity matrix
matrix = wgpuMatrix.mat4.create( 1,0,0,0, 0,1,0,0, 0,0,1,0, 2,3,4,1 );
console.log( wgpuMatrix.mat4.multiply( matrix, wgpuMatrix.mat4.inverse(matrix) ) );
// outputs the identity matrix
</script>
The text was updated successfully, but these errors were encountered:
It seems like mat3.inverse() in version 2.4.0 actually computes the transpose of the inverse. mat4.inverse() is OK. I was trying to use gpu-matrix to compute a normal vector transformation matrix -- a mat3.normalMatrixFromMat4() function would be a good addition.
<script src="wgpu-matrix.js"></script> <script> let matrix = wgpuMatrix.mat3.create( 1,0,0, 0,1,0, 2,3,1 ); console.log( wgpuMatrix.mat3.multiply( matrix, wgpuMatrix.mat3.inverse(matrix) ) ); // does not output the identity matrix console.log( wgpuMatrix.mat3.multiply( matrix, wgpuMatrix.mat3.transpose(wgpuMatrix.mat3.inverse(matrix)) ) ); // outputs the identity matrix matrix = wgpuMatrix.mat4.create( 1,0,0,0, 0,1,0,0, 0,0,1,0, 2,3,4,1 ); console.log( wgpuMatrix.mat4.multiply( matrix, wgpuMatrix.mat4.inverse(matrix) ) ); // outputs the identity matrix </script>The text was updated successfully, but these errors were encountered: