rhb-server/mes-ui/rhb-app/node_modules/gl-mat2/rotate.js
2025-10-20 11:14:41 +08:00

22 lines
512 B
JavaScript

module.exports = rotate
/**
* Rotates a mat2 by the given angle
*
* @alias mat2.rotate
* @param {mat2} out the receiving matrix
* @param {mat2} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat2} out
*/
function rotate(out, a, rad) {
var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3]
var s = Math.sin(rad)
var c = Math.cos(rad)
out[0] = a0 * c + a2 * s
out[1] = a1 * c + a3 * s
out[2] = a0 * -s + a2 * c
out[3] = a1 * -s + a3 * c
return out
}