diff --git a/src/math/Matrices/Matrix.js b/src/math/Matrices/Matrix.js index 91d3ecc263..e7d9748904 100644 --- a/src/math/Matrices/Matrix.js +++ b/src/math/Matrices/Matrix.js @@ -1856,9 +1856,12 @@ export class Matrix extends MatrixInterface { * @chainable */ #transpose3x3(mat3) { - if (mat3 === undefined) { + if (mat3 instanceof Matrix) { + mat3 = mat3.mat3; + } else if (mat3 === undefined) { mat3 = this.mat3; } + const a01 = mat3[1]; const a02 = mat3[2]; const a12 = mat3[5]; diff --git a/test/unit/math/p5.Matrix.js b/test/unit/math/p5.Matrix.js index 762d7f3779..7e0f03ca67 100644 --- a/test/unit/math/p5.Matrix.js +++ b/test/unit/math/p5.Matrix.js @@ -406,20 +406,18 @@ suite('p5.Matrix', function () { ]); }); - // TODO: matrix transpose This needs to be added to the legacy tests - it.skip('should transpose a 3x3 matrix correctly', () => { + it('should transpose a 3x3 matrix correctly', () => { const mat = new p5.Matrix([1, 2, 3, 4, 5, 6, 7, 8, 9]); mat.transpose(mat); - expect(mat.mat3).toEqual([1, 4, 7, 2, 5, 8, 3, 6, 9]); + expect(toArray(mat.mat3)).toEqual([1, 4, 7, 2, 5, 8, 3, 6, 9]); }); - // TODO: matrix transpose This needs to be added to the legacy tests - it.skip('should transpose a 3x3 matrix from an array correctly', () => { + it('should transpose a 3x3 matrix from an array correctly', () => { const mat = new p5.Matrix([1, 2, 3, 4, 5, 6, 7, 8, 9]); mat.transpose([1, 2, 3, 4, 5, 6, 7, 8, 9]); - expect(mat.mat3).toEqual([1, 4, 7, 2, 5, 8, 3, 6, 9]); + expect(toArray(mat.mat3)).toEqual([1, 4, 7, 2, 5, 8, 3, 6, 9]); }); }); describe.skip('Determinant', () => {