21 lines
374 B
JavaScript
21 lines
374 B
JavaScript
module.exports = adjoint
|
|
|
|
/**
|
|
* Calculates the adjugate of a mat2
|
|
*
|
|
* @alias mat2.adjoint
|
|
* @param {mat2} out the receiving matrix
|
|
* @param {mat2} a the source matrix
|
|
* @returns {mat2} out
|
|
*/
|
|
function adjoint(out, a) {
|
|
// Caching this value is nessecary if out == a
|
|
var a0 = a[0]
|
|
out[0] = a[3]
|
|
out[1] = -a[1]
|
|
out[2] = -a[2]
|
|
out[3] = a0
|
|
|
|
return out
|
|
}
|