[p5.js 2.0+ Bug Report]: 3x3 p5.Matrix.transpose() ignores passed matrix/array input and produces incorrect results

Open Beginner friendly
#9,197 3 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript

Research direction

Start with p5.Matrix.transpose() and the skipped tests in test/unit/math/p5.Matrix.js. Reproduce both 3x3 calls using a matrix and an array, then make the behavior match the expected transposed values [1, 4, 7, 2, 5, 8, 3, 6, 9] and run the relevant matrix tests.

Written by the indexing model from the issue text.

Description

Area:Math p5.js 2.0+
Most appropriate sub-area of p5.js?
  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • WebGPU
  • p5.strands
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
p5.js version

No response

Web browser and version

No response

Operating system

No response

Steps to reproduce this

The p5.Matrix.transpose() method is incorrectly handling the 3x3 case when a source matrix or array is passed in.

Current implementation does not reliably transpose the supplied source matrix and can leave the result incorrect or inconsistent. The skipped tests already describe this expected behavior in test/unit/math/p5.Matrix.js.

Steps:
  1. Create a 3x3 matrix using new p5.Matrix([1, 2, 3, 4, 5, 6, 7, 8, 9])
  2. Call transpose() with the matrix itself or with a 3x3 array:
mat.transpose(mat)
mat.transpose([1, 2, 3, 4, 5, 6, 7, 8, 9])
  1. Compare the result to the expected transposed matrix [1, 4, 7, 2, 5, 8, 3, 6, 9]
Snippet:

const mat = new p5.Matrix([1, 2, 3, 4, 5, 6, 7, 8, 9]);

console.log(mat.transpose(mat).mat3);
// expected: [1, 4, 7, 2, 5, 8, 3, 6, 9]

console.log(mat.transpose([1, 2, 3, 4, 5, 6, 7, 8, 9]).mat3);
// expected: [1, 4, 7, 2, 5, 8, 3, 6, 9]

Can i be assigned this issue @limzykenneth @perminder-17

Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 9h
Merged PRs (30d)
26

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from processing/p5.js

All issues in processing/p5.js

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.