Absolute value operations on vector classes - #2962
Open
AfonsoDGBatista wants to merge 5 commits into
Open
AfonsoDGBatista wants to merge 5 commits into
AfonsoDGBatista wants to merge 5 commits into
Conversation
Add methods to compute absolute values of Vector2f components.
Added methods to compute absolute values of vector components.
Added methods to compute absolute values of vector components.
| y = Math.abs(y); | ||
| z = Math.abs(z); | ||
| return this; | ||
| } |
Contributor
There was a problem hiding this comment.
The six new public methods have no test coverage. jme3-core/src/test/java/com/jme3/math/Vector3fTest.java exercises essentially every other public method of Vector3f (including maxLocal, minLocal, negate), so abs()/absLocal() should get matching tests there. Worth asserting the edge cases the existing suite cares about: negative components, -0.0f (→ +0.0f), and NaN propagation. Vector2f/Vector4f have no test classes, so covering the Vector3f variants is the minimum.
jaime-jmebot
suggested changes
Sep 17, 2026
jaime-jmebot
left a comment
Contributor
There was a problem hiding this comment.
- The added logic is correct:
abs()/absLocal()follow the engine's...Localnaming, andMath.absmaps-0.0fto+0.0fand propagates NaN consistently with the rest ofcom.jme3.math. - Two formatting violations (missing space after a comma) in
Vector3f.abs()andVector4f.abs(); committable one-line fixes are posted inline. - No tests for the six new methods.
Vector3fTestis the established home for per-method vector tests and should be extended to cover the abs variants, including-0.0fand NaN inputs. - Per CONTRIBUTING.md, non-trivial additions are expected to start with a forum thread; link the discussion in the PR description if one exists.
JNightRider
reviewed
Sep 19, 2026
JNightRider
left a comment
Contributor
There was a problem hiding this comment.
It appears that java.lang.Math is being used. Since FastMath has this same method, shouldn't we take advantage of the FastMath class instead of the Math class?
Added missing space Co-authored-by: Jaime Bot <jaime@rblb.it>
Added missing spaces Co-authored-by: Jaime Bot <jaime@rblb.it>
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.
Added abs and absLocal methods on Vector2f, Vector3f and Vector4f classes.