UNPKG

@jscad/modeling

Version:

Constructive Solid Geometry (CSG) Library for JSCAD

25 lines (22 loc) 512 B
/** * Computes the cross product of the given vectors (AxB). * * @param {vec3} out - receiving vector * @param {vec3} a - first operand * @param {vec3} b - second operand * @returns {vec3} out * @alias module:modeling/maths/vec3.cross */ const cross = (out, a, b) => { const ax = a[0] const ay = a[1] const az = a[2] const bx = b[0] const by = b[1] const bz = b[2] out[0] = ay * bz - az * by out[1] = az * bx - ax * bz out[2] = ax * by - ay * bx return out } module.exports = cross