Repository navigation
fix: rotate a point in place correctly in Point.rotate - #12335
Merged
Merged
Conversation
NgoQuocViet2001
requested review from
GoodBoyDigital,
Zyie and
bigtimebuddy
as code owners
October 24, 2026 15:22
Zyie
approved these changes
Nov 11, 2026
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of change
Point.rotate(radians, outPoint)from math-extras gives a wrong result whenoutPointis the point itself. It writesoutPoint.xfirst and then readsthis.xagain to computey, soyis built from the already rotatedx. For example,const p = new Point(2, 3); p.rotate(Math.PI / 4, p)givesy = 1.62instead of3.54, andnew Point(1, 0)rotated 90 degrees in place ends up near(0, 0)instead of(0, 1).ObservablePointbehaves the same way. The other point mixins (add,normalize,reflect, ...) already handle this case.This reads
xandyinto locals before writing, likeMatrix.applydoes, and adds a test that rotates aPointand anObservablePointin place and checks the values.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).npx jest --config .configs/jest.config.js --testPathPattern=math. 16 suites, 163 tests pass.npx eslint --max-warnings 0 src/math-extrasandtsc --noEmitoversrc/mathsandsrc/math-extras, both clean.Pre-Merge Checklist
npm run lint)npm run test)