Skip to content

fix: rotate a point in place correctly in Point.rotate - #12335

Merged
Zyie merged 2 commits into
pixijs:devfrom
NgoQuocViet2001:fix-point-rotate-in-place
Nov 11, 2026
Merged

Zyie merged 2 commits into
pixijs:devfrom
NgoQuocViet2001:fix-point-rotate-in-place

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown
Contributor
Description of change

Point.rotate(radians, outPoint) from math-extras gives a wrong result when outPoint is the point itself. It writes outPoint.x first and then reads this.x again to compute y, so y is built from the already rotated x. For example, const p = new Point(2, 3); p.rotate(Math.PI / 4, p) gives y = 1.62 instead of 3.54, and new Point(1, 0) rotated 90 degrees in place ends up near (0, 0) instead of (0, 1). ObservablePoint behaves the same way. The other point mixins (add, normalize, reflect, ...) already handle this case.

This reads x and y into locals before writing, like Matrix.apply does, and adds a test that rotates a Point and an ObservablePoint in place and checks the values.

  • Ran: npx jest --config .configs/jest.config.js src/math-extras/__tests__/Point.test.ts. The new test fails on dev (y = 1.62 vs 3.54) and passes with the fix (35/35).
  • Ran: npx jest --config .configs/jest.config.js --testPathPattern=math. 16 suites, 163 tests pass.
  • Checked: npx eslint --max-warnings 0 src/math-extras and tsc --noEmit over src/maths and src/math-extras, both clean.
Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

@Zyie Zyie added the ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t label Nov 11, 2026
@pkg-pr-new

pkg-pr-new Bot commented Nov 11, 2026

Copy link
Copy Markdown

commit: 4499e33

@Zyie
Zyie added this pull request to the merge queue Nov 11, 2026
Merged via the queue into pixijs:dev with commit 1d91549 Nov 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants