Add friendly warning when p5.Vector.cross() is called on non-3D vectors#8944
Draft
harshiltewari2004 wants to merge 1 commit into
Draft
Add friendly warning when p5.Vector.cross() is called on non-3D vectors#8944harshiltewari2004 wants to merge 1 commit into
harshiltewari2004 wants to merge 1 commit into
Conversation
19 tasks
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.
Resolves #8925
Changes:
p5.Vector.cross()now emits a non-blocking friendly warning (via_friendlyError) when either vector isn't 3D, since the cross product is only defined in 3D. The result is still computed from the x/y/z components — behavior is otherwise unchanged.@exampleblocks incross()'s reference docs, which used 2D vectors and a staletoString()output. They now use 3D vectors and show the correctvector[...]output.test/unit/math/p5.Vector.js:cross()warns for non-3D input (2D and >3D),cross()stays quiet for two 3D vectors, and no-leak guards forangleBetween()andslerp().Note on the two failing tests (opening as a draft for this reason):
angleBetween()andslerp()both callcross()internally on the raw input vectors, so the new warning currently leaks through them for legitimate 2D input. The two no-leak tests are guards that turn green once #8926 (angleBetween) and #8928 (slerp) decouple those methods fromcross().Screenshots of the change:
N/A — adds a console warning and fixes reference examples; no visual output change.
PR Checklist
npm run lintpasses