Changed license to Creative Commons Zero (CC0).
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / math / Transform.java
1 /*
2  * Sixth 3D engine. Author: Svjatoslav Agejenko. 
3  * This project is released under Creative Commons Zero (CC0) license.
4  *
5 *
6  */
7
8 package eu.svjatoslav.sixth.e3d.math;
9
10 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
11
12 public class Transform implements Cloneable {
13
14     private final Point3D translation;
15     private final Orientation orientation;
16
17     public Transform() {
18         translation = new Point3D();
19         orientation = new Orientation();
20     }
21
22     public Transform(final Point3D translation) {
23         this.translation = translation;
24         orientation = new Orientation();
25     }
26
27     public Transform(final Point3D translation, final double angleXZ,
28                      final double angleYZ) {
29
30         this.translation = translation;
31         orientation = new Orientation(angleXZ, angleYZ);
32     }
33
34     public Transform(final Point3D translation, final Orientation orientation) {
35         this.translation = translation;
36         this.orientation = orientation;
37     }
38
39     @Override
40     public Transform clone() {
41         return new Transform(translation, orientation);
42     }
43
44     public Orientation getOrientation() {
45         return orientation;
46     }
47
48     public Point3D getTranslation() {
49         return translation;
50     }
51
52     public void transform(final Point3D point) {
53         orientation.rotate(point);
54         point.add(translation);
55     }
56
57 }