diff options
author | Sven Gothel <[email protected]> | 2023-04-28 11:14:40 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-04-28 11:14:40 +0200 |
commit | b4b6061918d73bce53f5bcc4faf994b8a42c2c7d (patch) | |
tree | 02300341a4120d8081caa6435044a538c7ee9cb7 /src/jogl/classes/com | |
parent | 2aae33b94cea15b2fc0c54479277611c67cdaf13 (diff) |
Vec[234]f: Add 'max' and 'min' function
Diffstat (limited to 'src/jogl/classes/com')
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/math/Vec2f.java | 13 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/math/Vec3f.java | 15 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/math/Vec4f.java | 17 |
3 files changed, 45 insertions, 0 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java b/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java index 20628d949..47d1a78dc 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java @@ -121,6 +121,19 @@ public final class Vec2f { public void setX(final float x) { this.x = x; } public void setY(final float y) { this.y = y; } + /** this = max(this, m), returns this. */ + public Vec2f max(final Vec2f m) { + this.x = Math.max(this.x, m.x); + this.y = Math.max(this.y, m.y); + return this; + } + /** this = min(this, m), returns this. */ + public Vec2f min(final Vec2f m) { + this.x = Math.min(this.x, m.x); + this.y = Math.min(this.y, m.y); + return this; + } + /** Returns this * val; creates new vector */ public Vec2f mul(final float val) { return new Vec2f(this).scale(val); diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java b/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java index fbcd1e9a5..eb1144c07 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java @@ -149,6 +149,21 @@ public final class Vec3f { public void setY(final float y) { this.y = y; } public void setZ(final float z) { this.z = z; } + /** this = max(this, m), returns this. */ + public Vec3f max(final Vec3f m) { + this.x = Math.max(this.x, m.x); + this.y = Math.max(this.y, m.y); + this.z = Math.max(this.z, m.z); + return this; + } + /** this = min(this, m), returns this. */ + public Vec3f min(final Vec3f m) { + this.x = Math.min(this.x, m.x); + this.y = Math.min(this.y, m.y); + this.z = Math.min(this.z, m.z); + return this; + } + /** Returns this * val; creates new vector */ public Vec3f mul(final float val) { return new Vec3f(this).scale(val); diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec4f.java b/src/jogl/classes/com/jogamp/opengl/math/Vec4f.java index 254566ae0..f86fe5dad 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Vec4f.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Vec4f.java @@ -140,6 +140,23 @@ public final class Vec4f { public void setZ(final float z) { this.z = z; } public void setW(final float w) { this.w = w; } + /** this = max(this, m), returns this. */ + public Vec4f max(final Vec4f m) { + this.x = Math.max(this.x, m.x); + this.y = Math.max(this.y, m.y); + this.z = Math.max(this.z, m.z); + this.w = Math.max(this.w, m.w); + return this; + } + /** this = min(this, m), returns this. */ + public Vec4f min(final Vec4f m) { + this.x = Math.min(this.x, m.x); + this.y = Math.min(this.y, m.y); + this.z = Math.min(this.z, m.z); + this.w = Math.min(this.w, m.w); + return this; + } + /** Returns this * val; creates new vector */ public Vec4f mul(final float val) { return new Vec4f(this).scale(val); |