Skip to content
5 changes: 4 additions & 1 deletion src/math/Matrices/Matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
10 changes: 4 additions & 6 deletions test/unit/math/p5.Matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading