Skip to content

Conversation

@Mexicoco
Copy link

Summary

  • Fix incorrect cross product formula in MathUtils
  • Before: p1x * p2x - p1y * p2y (wrong)
  • After: p1x * p2y - p1y * p2x (correct)

The 2D cross product should compute A × B = Ax * By - Ay * Bx, which returns the z-component of the 3D cross product.

Test

cross(1, 0, 0, 1) // Now correctly returns 1 (was returning 0)

The cross product formula was incorrect:
- Before: p1x * p2x - p1y * p2y (wrong)
- After: p1x * p2y - p1y * p2x (correct)

The 2D cross product (perp dot product) should compute:
A × B = Ax * By - Ay * Bx

This returns the z-component of the 3D cross product when
treating 2D vectors as 3D vectors with z=0.

Also fixed the example comment to show correct result.
@JYsoon JYsoon merged commit 37dfbb2 into soonfx-engine:main Dec 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants