rhb-server/mes-ui/rhb-app/node_modules/gl-vec2/rotate.js

23 lines
416 B
JavaScript
Raw Normal View History

2025-10-20 11:14:41 +08:00
module.exports = rotate
/**
* Rotates a vec2 by an angle
*
* @param {vec2} out the receiving vector
* @param {vec2} a the vector to rotate
* @param {Number} angle the angle of rotation (in radians)
* @returns {vec2} out
*/
function rotate(out, a, angle) {
var c = Math.cos(angle),
s = Math.sin(angle)
var x = a[0],
y = a[1]
out[0] = x * c - y * s
out[1] = x * s + y * c
return out
}