X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=sixth-3d.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fgeometry%2FPoint3D.java;h=f0f23905a9171ee280ccfae6124487b0e27bfd5c;hp=ec38ef9b39097a7cecdf916a297a6019ee623665;hb=2ba2ce636354885e669e9e3fbb97226025e5af45;hpb=4aed7dc533afbe984df90d25d9055a5c75d62dc5 diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point3D.java b/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point3D.java index ec38ef9..f0f2390 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point3D.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point3D.java @@ -15,9 +15,9 @@ import static java.lang.Math.*; * Used to represent point in a 3D space or vector. */ -public class Point3D extends Point2D implements Cloneable { +public class Point3D implements Cloneable { - public double z; + public double x, y, z; public Point3D() { } @@ -47,12 +47,12 @@ public class Point3D extends Point2D implements Cloneable { } public Point3D add(final Point3D direction) { - super.add(direction); + x += direction.x; + y += direction.y; z += direction.z; return this; } - @Override public Point3D clone() { return new Point3D(this); } @@ -71,7 +71,6 @@ public class Point3D extends Point2D implements Cloneable { return this; } - @Override public boolean isZero() { return (x == 0) && (y == 0) && (z == 0); } @@ -84,6 +83,10 @@ public class Point3D extends Point2D implements Cloneable { return Math.atan2(y - anotherPoint.y, z - anotherPoint.z); } + public double getAngleXY(final Point3D anotherPoint) { + return Math.atan2(x - anotherPoint.x, y - anotherPoint.y); + } + /** * Compute distance to another point. */ @@ -95,12 +98,10 @@ public class Point3D extends Point2D implements Cloneable { return sqrt(((xDelta * xDelta) + (yDelta * yDelta) + (zDelta * zDelta))); } - @Override public double getVectorLength() { return sqrt(((x * x) + (y * y) + (z * z))); } - @Override public Point3D invert() { x = -x; y = -y; @@ -131,7 +132,6 @@ public class Point3D extends Point2D implements Cloneable { z = z2 + center.z; } - @Override public void roundToInteger() { x = (int) x; y = (int) y; @@ -159,7 +159,8 @@ public class Point3D extends Point2D implements Cloneable { } public Point3D subtract(final Point3D direction) { - super.subtract(direction); + x -= direction.x; + y -= direction.y; z -= direction.z; return this; } @@ -196,9 +197,9 @@ public class Point3D extends Point2D implements Cloneable { return false; } - @Override public Point3D zero() { - super.zero(); + x = 0; + y = 0; z = 0; return this; }