Bug Fix: Dot and Cross Product Visualizations (BUG-020)#331
Merged
mattqdev merged 1 commit intoMay 29, 2026
Merged
Conversation
…mpat - BUG-020: VectorsOperations cross product now renders a shaded parallelogram instead of three identical lines; dot product now renders a projection of A onto B with a right-angle marker - Add instrumentation.ts to patch Node.js 22+ broken localStorage global (getItem/setItem are undefined without --localstorage-file) which caused a TypeError during Next.js SSR on Node.js 22+ - Harden useTheme.tsx localStorage access with window.localStorage and try-catch as an additional defensive layer
|
@TechGenius-Karan is attempting to deploy a commit to the PhysicsHub's projects Team on Vercel. A member of the Team first needs to authorize it. |
Collaborator
|
Hey! Thank you for this! |
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.
📘 Pull Request Template – PhysicsHub
Thank you for contributing to PhysicsHub!
Please complete the sections below to help us review your pull request efficiently.
🔍 Description
What was wrong:
The VectorsOperations simulation had both the dot product and cross product modes drawing identical
visuals — just three plain lines for vectors A, B, and a result. There was no visual difference
between the two operations, making the simulation useless for understanding what each operation
actually means geometrically.
What was fixed:
geometric representation (the magnitude of the cross product equals the area of this
parallelogram). The result vector is drawn perpendicular to indicate the out-of-plane direction.
foot of the projection — showing the geometric meaning of the dot product as "how much of A points
in the direction of B."
Bug Fix: Node.js 22+ SSR Compatibility (localStorage TypeError)
What was wrong:
Node.js 22 and above ships with a built-in localStorage global. However, without a
--localstorage-file path configured, the object exists but its methods (getItem, setItem, etc.) are
undefined. When Next.js renders pages on the server, it hits this broken global and throws:
TypeError: localStorage.getItem is not a function
This caused the entire app to return a 500 error on every page load.
What was fixed:
localStorage stub and replaces it with a safe in-memory no-op before any rendering happens. This
only runs on the server — browsers continue using real localStorage normally.
defensive layer.
Closes #BUG-020 (if applicable)
✅ Checklist
Before requesting a review, please ensure that you have:
npm run dev)🎨 Visual Changes (if UI-related)
Visual Changes – Before & After
Before (both modes looked identical):
Both modes rendered the same three plain lines — there was no visual difference between them,
making the simulation misleading.
After:
Dot Product (After) :
Dot Product — Shows vector A projected onto vector B, with a right-angle marker at the base of the
projection. Make sure to select "Dot Product" from the operation dropdown to see this view.
Cross Product (After) :


Cross Product — Shows a shaded parallelogram formed by vectors A and B. The area of this
parallelogram represents the magnitude of the cross product.
📂 Type of Change
🧩 Additional Notes for Reviewers
Maybe try running these changes on your local system first, before merging it directly. The localStorage issue was a big problem on my system, but I am not sure if it is the same for everyone.