diff options
author | Sven Göthel <[email protected]> | 2024-01-26 01:18:21 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-01-26 01:18:21 +0100 |
commit | 09c256e2f26938cc2015176e259164bd7421dbdd (patch) | |
tree | 22e35811b481d4dd1e2688b4257fbb59af1b1831 /src/jogl/classes/com/jogamp/math | |
parent | 8fe39d3a524e5e580cf2667988965f1e27fed95b (diff) |
Math Vec*: Rename {scale->mul}(..) for non-scalar types (n-dim); Add div(..)
Diffstat (limited to 'src/jogl/classes/com/jogamp/math')
-rw-r--r-- | src/jogl/classes/com/jogamp/math/Matrix4f.java | 20 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/math/Vec2f.java | 30 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/math/Vec3d.java | 34 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/math/Vec3f.java | 34 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/math/Vec4f.java | 38 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/math/geom/AABBox.java | 8 |
6 files changed, 114 insertions, 50 deletions
diff --git a/src/jogl/classes/com/jogamp/math/Matrix4f.java b/src/jogl/classes/com/jogamp/math/Matrix4f.java index b82f92727..06e20ed01 100644 --- a/src/jogl/classes/com/jogamp/math/Matrix4f.java +++ b/src/jogl/classes/com/jogamp/math/Matrix4f.java @@ -1797,10 +1797,10 @@ public class Matrix4f { final Vec4f winPos = new Vec4f(winx, winy, winz, 1f); // Map x and y from window coordinates - winPos.add(-viewport.x(), -viewport.y(), 0f, 0f).scale(1f/viewport.width(), 1f/viewport.height(), 1f, 1f); + winPos.add(-viewport.x(), -viewport.y(), 0f, 0f).mul(1f/viewport.width(), 1f/viewport.height(), 1f, 1f); // Map to range -1 to 1 - winPos.scale(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f); + winPos.mul(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f); // rawObjPos = Inv(P x Mv) * winPos final Vec4f rawObjPos = invPMv.mulVec4f(winPos, new Vec4f()); @@ -1838,10 +1838,10 @@ public class Matrix4f { final Vec4f winPos = new Vec4f(winx, winy, winz, 1f); // Map x and y from window coordinates - winPos.add(-viewport.x(), -viewport.y(), 0f, 0f).scale(1f/viewport.width(), 1f/viewport.height(), 1f, 1f); + winPos.add(-viewport.x(), -viewport.y(), 0f, 0f).mul(1f/viewport.width(), 1f/viewport.height(), 1f, 1f); // Map to range -1 to 1 - winPos.scale(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f); + winPos.mul(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f); // rawObjPos = Inv(P x Mv) * winPos final Vec4f rawObjPos = invPMv.mulVec4f(winPos, new Vec4f()); @@ -1881,10 +1881,10 @@ public class Matrix4f { final Vec4f winPos = new Vec4f(winx, winy, winz1, 1f); // Map x and y from window coordinates - winPos.add(-viewport.x(), -viewport.y(), 0f, 0f).scale(1f/viewport.width(), 1f/viewport.height(), 1f, 1f); + winPos.add(-viewport.x(), -viewport.y(), 0f, 0f).mul(1f/viewport.width(), 1f/viewport.height(), 1f, 1f); // Map to range -1 to 1 - winPos.scale(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f); + winPos.mul(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f); // rawObjPos = Inv(P x Mv) * winPos1 final Vec4f rawObjPos = invPMv.mulVec4f(winPos, new Vec4f()); @@ -1946,10 +1946,10 @@ public class Matrix4f { final Vec4f winPos = new Vec4f(winx, winy, winz, clipw); // Map x and y from window coordinates - winPos.add(-viewport.x(), -viewport.y(), -near, 0f).scale(1f/viewport.width(), 1f/viewport.height(), 1f/(far-near), 1f); + winPos.add(-viewport.x(), -viewport.y(), -near, 0f).mul(1f/viewport.width(), 1f/viewport.height(), 1f/(far-near), 1f); // Map to range -1 to 1 - winPos.scale(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f); + winPos.mul(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f); // objPos = Inv(P x Mv) * winPos invPMv.mulVec4f(winPos, objPos); @@ -1989,10 +1989,10 @@ public class Matrix4f { final Vec4f winPos = new Vec4f(winx, winy, winz, clipw); // Map x and y from window coordinates - winPos.add(-viewport.x(), -viewport.y(), -near, 0f).scale(1f/viewport.width(), 1f/viewport.height(), 1f/(far-near), 1f); + winPos.add(-viewport.x(), -viewport.y(), -near, 0f).mul(1f/viewport.width(), 1f/viewport.height(), 1f/(far-near), 1f); // Map to range -1 to 1 - winPos.scale(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f); + winPos.mul(2f, 2f, 2f, 1f).add(-1f, -1f, -1f, 0f); // objPos = Inv(P x Mv) * winPos invPMv.mulVec4f(winPos, objPos); diff --git a/src/jogl/classes/com/jogamp/math/Vec2f.java b/src/jogl/classes/com/jogamp/math/Vec2f.java index 27371401a..547f63a05 100644 --- a/src/jogl/classes/com/jogamp/math/Vec2f.java +++ b/src/jogl/classes/com/jogamp/math/Vec2f.java @@ -147,21 +147,35 @@ public final class Vec2f { } /** this = this * s, returns this. */ - public Vec2f scale(final float s) { - x *= s; - y *= s; - return this; - } + public Vec2f mul(final Vec2f s) { return mul(s.x, s.y); } /** this = this * { sx, sy }, returns this. */ - public Vec2f scale(final float sx, final float sy) { + public Vec2f mul(final float sx, final float sy) { x *= sx; y *= sy; return this; } - /** this = this * { s.x, s.y }, returns this. */ - public Vec2f scale(final Vec2f s) { return scale(s.x, s.y); } + /** this = a / b, returns this. */ + public Vec2f div(final Vec2f a, final Vec2f b) { + x = a.x / b.x; + y = a.y / b.y; + return this; + } + + /** this = this / a, returns this. */ + public Vec2f div(final Vec2f a) { + x /= a.x; + y /= a.y; + return this; + } + + /** this = this * s, returns this. */ + public Vec2f scale(final float s) { + x *= s; + y *= s; + return this; + } /** Returns this + arg; creates new vector */ public Vec2f plus(final Vec2f arg) { diff --git a/src/jogl/classes/com/jogamp/math/Vec3d.java b/src/jogl/classes/com/jogamp/math/Vec3d.java index 14408f714..7fb4477e0 100644 --- a/src/jogl/classes/com/jogamp/math/Vec3d.java +++ b/src/jogl/classes/com/jogamp/math/Vec3d.java @@ -173,23 +173,39 @@ public final class Vec3d { } /** this = this * s, returns this. */ - public Vec3d scale(final double s) { - x *= s; - y *= s; - z *= s; - return this; - } + public Vec3d mul(final Vec3d s) { return mul(s.x, s.y, s.z); } /** this = this * { sx, sy, sz }, returns this. */ - public Vec3d scale(final double sx, final double sy, final double sz) { + public Vec3d mul(final double sx, final double sy, final double sz) { x *= sx; y *= sy; z *= sz; return this; } - /** this = this * { s.x, s.y, s.z }, returns this. */ - public Vec3d scale(final Vec3d s) { return scale(s.x, s.y, s.z); } + /** this = a / b, returns this. */ + public Vec3d div(final Vec3d a, final Vec3d b) { + x = a.x / b.x; + y = a.y / b.y; + z = a.z / b.z; + return this; + } + + /** this = this / a, returns this. */ + public Vec3d div(final Vec3d a) { + x /= a.x; + y /= a.y; + z /= a.z; + return this; + } + + /** this = this * s, returns this. */ + public Vec3d scale(final double s) { + x *= s; + y *= s; + z *= s; + return this; + } /** Returns this + arg; creates new vector */ public Vec3d plus(final Vec3d arg) { diff --git a/src/jogl/classes/com/jogamp/math/Vec3f.java b/src/jogl/classes/com/jogamp/math/Vec3f.java index 1ad27463e..2dc399ef1 100644 --- a/src/jogl/classes/com/jogamp/math/Vec3f.java +++ b/src/jogl/classes/com/jogamp/math/Vec3f.java @@ -180,23 +180,39 @@ public final class Vec3f { } /** this = this * s, returns this. */ - public Vec3f scale(final float s) { - x *= s; - y *= s; - z *= s; - return this; - } + public Vec3f mul(final Vec3f s) { return mul(s.x, s.y, s.z); } /** this = this * { sx, sy, sz }, returns this. */ - public Vec3f scale(final float sx, final float sy, final float sz) { + public Vec3f mul(final float sx, final float sy, final float sz) { x *= sx; y *= sy; z *= sz; return this; } - /** this = this * { s.x, s.y, s.z }, returns this. */ - public Vec3f scale(final Vec3f s) { return scale(s.x, s.y, s.z); } + /** this = a / b, returns this. */ + public Vec3f div(final Vec3f a, final Vec3f b) { + x = a.x / b.x; + y = a.y / b.y; + z = a.z / b.z; + return this; + } + + /** this = this / a, returns this. */ + public Vec3f div(final Vec3f a) { + x /= a.x; + y /= a.y; + z /= a.z; + return this; + } + + /** this = this * s, returns this. */ + public Vec3f scale(final float s) { + x *= s; + y *= s; + z *= s; + return this; + } /** Returns this + arg; creates new vector */ public Vec3f plus(final Vec3f arg) { diff --git a/src/jogl/classes/com/jogamp/math/Vec4f.java b/src/jogl/classes/com/jogamp/math/Vec4f.java index 45afea7f8..5b17d7a4c 100644 --- a/src/jogl/classes/com/jogamp/math/Vec4f.java +++ b/src/jogl/classes/com/jogamp/math/Vec4f.java @@ -172,16 +172,10 @@ public final class Vec4f { } /** this = this * s, returns this. */ - public Vec4f scale(final float s) { - x *= s; - y *= s; - z *= s; - w *= s; - return this; - } + public Vec4f mul(final Vec4f s) { return mul(s.x, s.y, s.z, s.w); } /** this = this * { sx, sy, sz, sw }, returns this. */ - public Vec4f scale(final float sx, final float sy, final float sz, final float sw) { + public Vec4f mul(final float sx, final float sy, final float sz, final float sw) { x *= sx; y *= sy; z *= sz; @@ -189,8 +183,32 @@ public final class Vec4f { return this; } - /** this = this * { s.x, s.y, s.z, s.w }, returns this. */ - public Vec4f scale(final Vec4f s) { return scale(s.x, s.y, s.z, s.w); } + /** this = a / b, returns this. */ + public Vec4f div(final Vec4f a, final Vec4f b) { + x = a.x / b.x; + y = a.y / b.y; + z = a.z / b.z; + w = a.w / b.w; + return this; + } + + /** this = this / a, returns this. */ + public Vec4f div(final Vec4f a) { + x /= a.x; + y /= a.y; + z /= a.z; + w /= a.w; + return this; + } + + /** this = this * s, returns this. */ + public Vec4f scale(final float s) { + x *= s; + y *= s; + z *= s; + w *= s; + return this; + } /** Returns this + arg; creates new vector */ public Vec4f plus(final Vec4f arg) { diff --git a/src/jogl/classes/com/jogamp/math/geom/AABBox.java b/src/jogl/classes/com/jogamp/math/geom/AABBox.java index 2b208267d..9d6153b7a 100644 --- a/src/jogl/classes/com/jogamp/math/geom/AABBox.java +++ b/src/jogl/classes/com/jogamp/math/geom/AABBox.java @@ -762,10 +762,10 @@ public class AABBox { */ public final AABBox scale(final float sX, final float sY, final float sZ) { final Vec3f tmp = new Vec3f(); - tmp.set(hi).sub(center).scale(sX, sY, sZ); + tmp.set(hi).sub(center).mul(sX, sY, sZ); hi.set(center).add(tmp); - tmp.set(lo).sub(center).scale(sX, sY, sZ); + tmp.set(lo).sub(center).mul(sX, sY, sZ); lo.set(center).add(tmp); return this; @@ -799,8 +799,8 @@ public class AABBox { * @see #scale(float, float[]) */ public final AABBox scale2(final float sX, final float sY, final float sZ) { - hi.scale(sX, sY, sZ); - lo.scale(sX, sY, sZ); + hi.mul(sX, sY, sZ); + lo.mul(sX, sY, sZ); computeCenter(); return this; } |