374880f8352fe169ad06550cbdf5d869001cca79
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / geometry / Transform.java
1 /*
2  * Sixth 3D engine. Copyright ©2012-2018, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of version 3 of the GNU Lesser General Public License
6  * or later as published by the Free Software Foundation.
7  *
8  */
9
10 package eu.svjatoslav.sixth.e3d.geometry;
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 }