-
Notifications
You must be signed in to change notification settings - Fork 14
KGL-Math #19
base: master
Are you sure you want to change the base?
KGL-Math #19
Conversation
no need for separate android target, uses jvm
Should there be in-place-modifying variants of |
I think there should be. Definitely as extension functions. Naming will be difficult for some of them. Like |
The naming is going to be very diifficult, or ugly, depending on whether we insist on nice names, or we use a name like |
Actually, what is |
Ooh, add quaternions to the list. |
quaternions are part of the recommended extensions (GTC) in GLM. I'll be getting to those. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments.
U_BYTE, U_SHORT, U_INT, U_LONG -> | ||
"return sqrt((this dot this).toDouble()).to${type.simpleName.drop(1)}().to${type.simpleName}()" | ||
else -> | ||
"return sqrt(this dot this)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be sqrt(lengthSquared)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was intending to save a function call (of the lengthSquared
getter). Should I not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I trust the JVM to inline it but I'm not sure about LLVM. We can leave it until we start bench-marking.
kotlin poet line separation puts operator on the next line, which breaks without parentheses
Do we need a BooleanVector? |
I already think non-floating point vectors are pushing it a bit. So I'm gonna say no. |
Works for me. I don't see a use for them either, but could be added later if someone presents a usecase. |
remove many warnings and make things look better
So in implementing this a question came up: should Both the arithmetic operators and the normalize function are component-wise.
EDIT2: I take it back. The |
By component-wise, I mean you can run the operation on each component independently of other components. |
Got it 👌 |
x.abs / x.absAssign -> abs(x) / absInPlace(x) functions that in stdlib take a parameter will follow op / opInPlace, and extension functions will follow op / opAssign
# Conflicts: # buildSrc/src/main/kotlin/codegen/math/CoreFeatures.kt # buildSrc/src/main/kotlin/codegen/math/ExperimentalExtensions.kt # buildSrc/src/main/kotlin/codegen/math/GenerateMath.kt # buildSrc/src/main/kotlin/codegen/math/StableExtensions.kt
So I now have basic implementations for the three common vector types and a 4 by 4 matrix, which is enough for view transforms. Still missing are a The tests are in place for all functions. The CI failed because it couldn't download stb in on of the runs, for some reason. |
It occasionally happens (Might be worth throwing in some retry logic in there at some point). I've restarted the build, so it should work fine now. |
…and expose that storage through asFloatArray function on mutable types
I've shortened type names to only distinguishing information (EDIT2: actually writing out EDIT: I'd consider it ready for an alpha/beta release, though EDIT3: Having a full port of GLM in the new multiplatform version of the kotlin glm project seems like a better focus of efforts, although I think the current implementation here is either a good hold-over, or a good basic implementation if glm is too heavy. |
Ah. I'm just seeing this comment now for some reason. It does seem more productive to contribute to the glm project. It will probably end up being a top down rewrite as we shove Kotlin in and pull C out of it. I'll probably merge this into a math branch and publish it with a different version suffix. Like |
In that case I'm gonna say this PR is no longer WIP. Let me know if you need me to change anything about the PR so it can be pulled into the correct branch. |
Kotlinic basic implementation of vector and 4 by 4 matrix types to allow for basic 3d transformation.