/*
- * Sixth 3D engine. Copyright ©2012-2018, 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.cos;
-import static java.lang.Math.sin;
-import static java.lang.Math.sqrt;
+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() {
}
}
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);
}
return this;
}
- @Override
- public boolean isZero(){
+ public boolean isZero() {
return (x == 0) && (y == 0) && (z == 0);
}
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.
*/
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;
z = z2 + center.z;
}
- @Override
public void roundToInteger() {
x = (int) x;
y = (int) y;
}
public Point3D subtract(final Point3D direction) {
- super.subtract(direction);
+ x -= direction.x;
+ y -= direction.y;
z -= direction.z;
return this;
}
return false;
}
- @Override
public Point3D zero() {
- super.zero();
+ x = 0;
+ y = 0;
z = 0;
return this;
}