17 lines
410 B
JavaScript
17 lines
410 B
JavaScript
module.exports = cross
|
|
|
|
/**
|
|
* Computes the cross product of two vec2's
|
|
* Note that the cross product must by definition produce a 3D vector
|
|
*
|
|
* @param {vec3} out the receiving vector
|
|
* @param {vec2} a the first operand
|
|
* @param {vec2} b the second operand
|
|
* @returns {vec3} out
|
|
*/
|
|
function cross(out, a, b) {
|
|
var z = a[0] * b[1] - a[1] * b[0]
|
|
out[0] = out[1] = 0
|
|
out[2] = z
|
|
return out
|
|
} |