Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Invert(ref Matrix3x2) #962

Merged
merged 2 commits into from
Nov 8, 2024
Merged

Conversation

Eb3yr
Copy link
Contributor

@Eb3yr Eb3yr commented Nov 8, 2024

Previously Matrix3x2 sequentially mutated the fields of the input ref matrix, so later elements would be computed from modified elements. Fixed by constructing and assigning a new struct to the input matrix.

Additionally added a check for the determinant equalling zero, which would set the reciprocal multiplier to infinity. Returns the Identity matrix in this case, as MM⁻¹=I for non-singular matrices. M⁻¹=I in the singular case would uphold this.

Resolves issue #960

* erroneous results were given by matrix fields being altered sequentially, some fields would use new state instead of the input

* Check for matrix.Determinant() = 0, now returns the identity instead of det becoming infinite"
Copy link
Member

@AristurtleDev AristurtleDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Eb3yr
Would it be possible to add a unit test for this change before merging?

@AristurtleDev AristurtleDev added this to the 4.0.4 Weekly Release milestone Nov 8, 2024
@Eb3yr
Copy link
Contributor Author

Eb3yr commented Nov 8, 2024

Added a test for two matrices with a positive and negative determinant, and for a matrix with a determinant of zero.

@AristurtleDev AristurtleDev merged commit 8b02498 into craftworkgames:develop Nov 8, 2024
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.

2 participants