UNPKG

@jscad/modeling

Version:

Constructive Solid Geometry (CSG) Library for JSCAD

21 lines (19 loc) 747 B
/** * Determine whether the given matrix is the identity transform. * This is equivalent to (but much faster than): * * mat4.equals(mat4.create(), matrix) * * @param {mat4} matrix - the matrix * @returns {Boolean} true if matrix is the identity transform * @alias module:modeling/maths/mat4.isIdentity * @example * if (mat4.isIdentity(mymatrix)) ... */ const isIdentity = (matrix) => ( matrix[0] === 1 && matrix[1] === 0 && matrix[2] === 0 && matrix[3] === 0 && matrix[4] === 0 && matrix[5] === 1 && matrix[6] === 0 && matrix[7] === 0 && matrix[8] === 0 && matrix[9] === 0 && matrix[10] === 1 && matrix[11] === 0 && matrix[12] === 0 && matrix[13] === 0 && matrix[14] === 0 && matrix[15] === 1 ) module.exports = isIdentity