/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.geometry;
+import eu.svjatoslav.sixth.e3d.renderer.octree.IntegerPoint;
+
import static java.lang.Math.*;
/**
this.z = z;
}
+ public Point3D(IntegerPoint point) {
+ this.x = point.x;
+ this.y = point.y;
+ this.z = point.z;
+ }
+
+
/**
* Creates new current point by cloning coordinates from parent point.
*/
return this;
}
+ /**
+ * Add coordinates of current point to other point. Value of current point will not be changed.
+ *
+ * @return current point.
+ */
+ public Point3D addTo(final Point3D... otherPoints) {
+ for (final Point3D otherPoint : otherPoints) otherPoint.add(this);
+ return this;
+ }
+
+ /**
+ * Create new point by cloning position of current point.
+ *
+ * @return newly created clone.
+ */
public Point3D clone() {
return new Point3D(this);
}
* <p>
* See also: <a href="https://marctenbosch.com/quaternions/">Let's remove Quaternions from every 3D Engine</a>
*
- * @param center center point.
+ * @param center center point.
* @param angleXZ angle around XZ axis.
* @param angleYZ angle around YZ axis.
*/
public Point3D rotate(final Point3D center, final double angleXZ,
- final double angleYZ) {
+ final double angleYZ) {
final double s1 = sin(angleXZ);
final double c1 = cos(angleXZ);
return this;
}
+ public Point3D rotate(final double angleXZ, final double angleYZ) {
+ return rotate(new Point3D(0, 0, 0), angleXZ, angleYZ);
+ }
+
/**
* Round current point coordinates to integer values.
*/
/**
* Set current point coordinates to given values.
+ *
* @param x X coordinate.
* @param y Y coordinate.
* @param z Z coordinate.