-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Expose determinant
in Transform2D, rename internal method
#76311
Conversation
I agree both with exposing and renaming it. It doesn't have anything to do with the Basis class, does it? |
Well, determinant makes sense only for square matrices. And Transform2D is said to be a 2×3 matrix. Given that,
@MewPurPur It does not, it has to do with the basis part of the Transform2D. |
Hmm, sure thing, but the determinant tells us what the area of a unit square would be under the matrix transformation and this is unaffected from changing the origin. For xform it's more relevant to tell this than for determinant. |
basis_determinant
in Transform2Ddeterminant
in Transform2D, rename internal method
d417e3d
to
b485fdd
Compare
Pushed an update to rename to
@MewPurPur Great point, it makes perfect sense conceptually when thinking about how the area changes, which is not affected by a translation.
It does make sense actually in fact you can even extend it into 4D. |
I'd consider Vector2.cross a shorthand notation for a mathematical hack, same for all cross products that aren't 3D or 7D. ... But that's off-topic :P |
@MewPurPur What I was saying is that without a square matrix there's no talk about the determinant in the first place. Determinant is defined only for square matrices. By saying "determinant" you're automatically referring to some square matrix (the 2x2 or 3x3 matrix I've mentioned in #76311 (comment)).
@aaronfranke Yeah, I've realized this about
@aaronfranke Was its supposed to link to a video about determinant? I'd expect something
The 2D case can be seen as a simplified 3D case with vectors' third component being zero, so it could be said to be a simplification and not really a hack though. Unless that's exactly what you call "a mathematical hack". 😄 |
@kleonc Oh, sorry, I linked the wrong video. I meant to link this video. But yeah we already agree :) |
b485fdd
to
290b09b
Compare
Thanks! |
I usually use 3D. As a math nerd I was helping out a friend with some math in a 2D game and I was shocked that the determinant was not exposed to GDScript. This PR exposes it.
Discussion: Since this is not exposed yet, we could also rename it from
basis_determinant
to justdeterminant
, since there is no other possible way to interpret the word "determinant" here. If this is desired I would be happy to add it to this PR, but I don't want to cause unnecessary friction so I haven't done so yet.basis_determinant
is still clear and correct, it's just... kinda redundant and unnecessary.3.x version: #76323