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=3ca7782bf7d7b20cd735f305af95003cf96c246f;hp=bd7a81daa3b855c908bfe6ef91a07ef4d18db496;hb=59baa428fb2d9e7f0fe5423f4cea47f2d6245914;hpb=03447008b8ee26a6463d2cd03005dc26464863db 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 bd7a81d..3ca7782 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point3D.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/geometry/Point3D.java @@ -1,5 +1,5 @@ /* - * Sixth 3D engine. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * 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 @@ -9,13 +9,14 @@ package eu.svjatoslav.sixth.e3d.geometry; +import static java.lang.Math.*; + /** - * Used to represent point in a 3D space, vector or speed. + * Used to represent point in a 3D space or vector. */ public class Point3D extends Point2D implements Cloneable { - public static final Point3D ZERO = new Point3D(); public double z; public Point3D() { @@ -70,6 +71,11 @@ public class Point3D extends Point2D implements Cloneable { return this; } + @Override + public boolean isZero() { + return (x == 0) && (y == 0) && (z == 0); + } + public double getAngleXZ(final Point3D anotherPoint) { return Math.atan2(x - anotherPoint.x, z - anotherPoint.z); } @@ -86,8 +92,12 @@ public class Point3D extends Point2D implements Cloneable { final double yDelta = y - anotherPoint.y; final double zDelta = z - anotherPoint.z; - return Math - .sqrt(((xDelta * xDelta) + (yDelta * yDelta) + (zDelta * zDelta))); + return sqrt(((xDelta * xDelta) + (yDelta * yDelta) + (zDelta * zDelta))); + } + + @Override + public double getVectorLength() { + return sqrt(((x * x) + (y * y) + (z * z))); } @Override @@ -100,11 +110,11 @@ public class Point3D extends Point2D implements Cloneable { public void rotate(final Point3D center, final double angleXZ, final double angleYZ) { - final double s1 = Math.sin(angleXZ); - final double c1 = Math.cos(angleXZ); + final double s1 = sin(angleXZ); + final double c1 = cos(angleXZ); - final double s2 = Math.sin(angleYZ); - final double c2 = Math.cos(angleYZ); + final double s2 = sin(angleYZ); + final double c2 = cos(angleYZ); x -= center.x; y -= center.y; @@ -174,7 +184,7 @@ public class Point3D extends Point2D implements Cloneable { return this; } - public boolean withinDrawingLimits() { + public boolean isVisible() { if (z > 0) return true;