X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fgeometry%2FPoint3D.java;h=54fbd357c07999ba8beaa17438b0f4d0fb2f6a93;hb=a40c9c2a3ef372ea0f2c87af644ca2302315baca;hp=3ca7782bf7d7b20cd735f305af95003cf96c246f;hpb=59baa428fb2d9e7f0fe5423f4cea47f2d6245914;p=sixth-3d.git 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 3ca7782..54fbd35 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point3D.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point3D.java @@ -1,12 +1,7 @@ /* - * Sixth 3D engine. Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 3 of the GNU Lesser General Public License - * or later as published by the Free Software Foundation. - * + * Sixth 3D engine. Author: Svjatoslav Agejenko. + * This project is released under Creative Commons Zero (CC0) license. */ - package eu.svjatoslav.sixth.e3d.geometry; import static java.lang.Math.*; @@ -15,9 +10,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 +42,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 +66,6 @@ public class Point3D extends Point2D implements Cloneable { return this; } - @Override public boolean isZero() { return (x == 0) && (y == 0) && (z == 0); } @@ -84,6 +78,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 +93,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 +127,6 @@ public class Point3D extends Point2D implements Cloneable { z = z2 + center.z; } - @Override public void roundToInteger() { x = (int) x; y = (int) y; @@ -159,7 +154,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 +192,9 @@ public class Point3D extends Point2D implements Cloneable { return false; } - @Override public Point3D zero() { - super.zero(); + x = 0; + y = 0; z = 0; return this; }