Updated readability of the code.
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / geometry / Point3D.java
index 1c8700a..6bf2dd3 100755 (executable)
@@ -58,6 +58,20 @@ public class Point3D implements Cloneable {
         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);
     }
@@ -147,7 +161,7 @@ public class Point3D implements Cloneable {
      * @param angleXZ angle around XZ axis.
      * @param angleYZ angle around YZ axis.
      */
-    public void rotate(final Point3D center, final double angleXZ,
+    public Point3D rotate(final Point3D center, final double angleXZ,
                        final double angleYZ) {
         final double s1 = sin(angleXZ);
         final double c1 = cos(angleXZ);
@@ -168,6 +182,12 @@ public class Point3D implements Cloneable {
         x = x1 + center.x;
         y = y1 + center.y;
         z = z2 + center.z;
+
+        return this;
+    }
+
+    public Point3D rotate(final double angleXZ, final double angleYZ) {
+        return rotate(new Point3D(0, 0, 0), angleXZ, angleYZ);
     }
 
     /**