2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.sixth.e3d.math;
7 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
10 * Used to represent transformation in a 3D space.
11 * Transformations are represented as a translation and an orientation.
13 public class Transform implements Cloneable {
15 private final Point3D translation;
16 private final Orientation orientation;
19 translation = new Point3D();
20 orientation = new Orientation();
24 * Creates a new transform with the specified translation.
26 * @param translation the translation
28 public Transform(final Point3D translation) {
29 this.translation = translation;
30 orientation = new Orientation();
34 * Creates a new transform with the specified translation and orientation.
36 * @param translation the translation
37 * @param angleXZ the angle around the XZ axis
38 * @param angleYZ the angle around the YZ axis
40 public Transform(final Point3D translation, final double angleXZ,
41 final double angleYZ) {
43 this.translation = translation;
44 orientation = new Orientation(angleXZ, angleYZ);
48 * Creates a new transform with the specified translation and orientation.
50 * @param translation the translation
51 * @param orientation the orientation
53 public Transform(final Point3D translation, final Orientation orientation) {
54 this.translation = translation;
55 this.orientation = orientation;
59 public Transform clone() {
60 return new Transform(translation, orientation);
63 public Orientation getOrientation() {
67 public Point3D getTranslation() {
71 public void transform(final Point3D point) {
72 orientation.rotate(point);
73 point.add(translation);