summaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Vec2f.java36
-rw-r--r--src/jogl/classes/com/jogamp/opengl/math/Vec3f.java46
2 files changed, 60 insertions, 22 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java b/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java
index 159a000df..0b67102fb 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Vec2f.java
@@ -32,7 +32,7 @@ package com.jogamp.opengl.math;
* 2D Vector based upon two float components.
*
* Implementation borrowed from [gfxbox2](https://jausoft.com/cgit/cs_class/gfxbox2.git/tree/include/pixel/pixel2f.hpp#n29)
- * and its layout from OpenAL's Vec3f.
+ * and its data layout from JOAL's Vec3f.
*/
public final class Vec2f {
private float x;
@@ -45,29 +45,40 @@ public final class Vec2f {
public Vec2f() {}
public Vec2f(final Vec2f o) {
- this.x = o.x;
- this.y = o.y;
+ set(o);
}
public Vec2f copy() {
return new Vec2f(this);
}
+ public Vec2f(final float[/*2*/] xy) {
+ set(xy);
+ }
+
public Vec2f(final float x, final float y) {
- this.x = x;
- this.y = y;
+ set(x, y);
}
+ /** this = o, returns this. */
public void set(final Vec2f o) {
this.x = o.x;
this.y = o.y;
}
+ /** this = { x, y }, returns this. */
public void set(final float x, final float y) {
this.x = x;
this.y = y;
}
+ /** this = xy, returns this. */
+ public Vec2f set(final float[/*2*/] xy) {
+ this.x = xy[0];
+ this.y = xy[1];
+ return this;
+ }
+
/** Sets the ith component, 0 <= i < 2 */
public void set(final int i, final float val) {
switch (i) {
@@ -97,7 +108,7 @@ public final class Vec2f {
return new Vec2f(this).scale(val);
}
- /** this = this * val */
+ /** this = this * val, returns this. */
public Vec2f scale(final float val) {
x *= val;
y *= val;
@@ -109,7 +120,14 @@ public final class Vec2f {
return new Vec2f(this).add(arg);
}
- /** this = this + b */
+ /** this = this + { dx, dy }, returns this. */
+ public Vec2f add(final float dx, final float dy) {
+ x += dx;
+ y += dy;
+ return this;
+ }
+
+ /** this = this + b, returns this. */
public Vec2f add(final Vec2f b) {
x += b.x;
y += b.y;
@@ -121,7 +139,7 @@ public final class Vec2f {
return new Vec2f(this).addScaled(s, arg);
}
- /** this = this + s * b */
+ /** this = this + s * b, returns this. */
public Vec2f addScaled(final float s, final Vec2f b) {
x += s * b.x;
y += s * b.y;
@@ -133,7 +151,7 @@ public final class Vec2f {
return new Vec2f(this).sub(arg);
}
- /** this = this - b */
+ /** this = this - b, returns this. */
public Vec2f sub(final Vec2f b) {
x -= b.x;
y -= b.y;
diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java b/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java
index 673f48b9a..9cead54c2 100644
--- a/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java
+++ b/src/jogl/classes/com/jogamp/opengl/math/Vec3f.java
@@ -32,7 +32,7 @@ package com.jogamp.opengl.math;
* 3D Vector based upon three float components.
*
* Implementation borrowed from [gfxbox2](https://jausoft.com/cgit/cs_class/gfxbox2.git/tree/include/pixel/pixel3f.hpp#n29)
- * and its layout from OpenAL's Vec3f.
+ * and its data layout from JOAL's Vec3f.
*/
public final class Vec3f {
private float x;
@@ -42,31 +42,43 @@ public final class Vec3f {
public Vec3f() {}
public Vec3f(final Vec3f o) {
- this.x = o.x;
- this.y = o.y;
- this.z = o.z;
+ set(o);
}
public Vec3f copy() {
return new Vec3f(this);
}
+ public Vec3f(final float[/*3*/] xyz) {
+ set(xyz);
+ }
+
public Vec3f(final float x, final float y, final float z) {
- this.x = x;
- this.y = y;
- this.z = z;
+ set(x, y, z);
}
- public void set(final Vec3f o) {
+ /** this = o, returns this. */
+ public Vec3f set(final Vec3f o) {
this.x = o.x;
this.y = o.y;
this.z = o.z;
+ return this;
}
- public void set(final float x, final float y, final float z) {
+ /** this = { x, y, z }, returns this. */
+ public Vec3f set(final float x, final float y, final float z) {
this.x = x;
this.y = y;
this.z = z;
+ return this;
+ }
+
+ /** this = xyz, returns this. */
+ public Vec3f set(final float[/*3*/] xyz) {
+ this.x = xyz[0];
+ this.y = xyz[1];
+ this.z = xyz[2];
+ return this;
}
/** Sets the ith component, 0 <= i < 3 */
@@ -102,7 +114,7 @@ public final class Vec3f {
return new Vec3f(this).scale(val);
}
- /** this = this * val */
+ /** this = this * val, returns this. */
public Vec3f scale(final float val) {
x *= val;
y *= val;
@@ -115,7 +127,15 @@ public final class Vec3f {
return new Vec3f(this).add(arg);
}
- /** this = this + b */
+ /** this = this + { dx, dy, dz }, returns this. */
+ public Vec3f add(final float dx, final float dy, final float dz) {
+ x += dx;
+ y += dy;
+ z += dz;
+ return this;
+ }
+
+ /** this = this + b, returns this. */
public Vec3f add(final Vec3f b) {
x += b.x;
y += b.y;
@@ -128,7 +148,7 @@ public final class Vec3f {
return new Vec3f(this).addScaled(s, arg);
}
- /** this = this + s * b */
+ /** this = this + s * b, returns this. */
public Vec3f addScaled(final float s, final Vec3f b) {
x += s * b.x;
y += s * b.y;
@@ -141,7 +161,7 @@ public final class Vec3f {
return new Vec3f(this).sub(arg);
}
- /** this = this - b */
+ /** this = this - b, returns this. */
public Vec3f sub(final Vec3f b) {
x -= b.x;
y -= b.y;