Refactoring.
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / math / Transform.java
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/math/Transform.java b/src/main/java/eu/svjatoslav/sixth/e3d/math/Transform.java
new file mode 100755 (executable)
index 0000000..059ba39
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ *
+ */
+
+package eu.svjatoslav.sixth.e3d.math;
+
+import eu.svjatoslav.sixth.e3d.geometry.Point3D;
+
+public class Transform implements Cloneable {
+
+    private final Point3D translation;
+    private final Orientation orientation;
+
+    public Transform() {
+        translation = new Point3D();
+        orientation = new Orientation();
+    }
+
+    public Transform(final Point3D translation) {
+        this.translation = translation;
+        orientation = new Orientation();
+    }
+
+    public Transform(final Point3D translation, final double angleXZ,
+                     final double angleYZ) {
+
+        this.translation = translation;
+        orientation = new Orientation(angleXZ, angleYZ);
+    }
+
+    public Transform(final Point3D translation, final Orientation orientation) {
+        this.translation = translation;
+        this.orientation = orientation;
+    }
+
+    @Override
+    public Transform clone() {
+        return new Transform(translation, orientation);
+    }
+
+    public Orientation getOrientation() {
+        return orientation;
+    }
+
+    public Point3D getTranslation() {
+        return translation;
+    }
+
+    public void transform(final Point3D point) {
+        orientation.rotate(point);
+        point.add(translation);
+    }
+
+}