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 {@link Orientation}.
13 public class Transform implements Cloneable {
16 * The translation is applied after the orientation.
18 private final Point3D translation;
21 * The orientation is applied before the translation.
23 private final Orientation orientation;
26 translation = new Point3D();
27 orientation = new Orientation();
31 * Creates a new transform with the specified translation.
33 * @param translation the translation
35 public Transform(final Point3D translation) {
36 this.translation = translation;
37 orientation = new Orientation();
41 * Creates a new transform with the specified translation and orientation.
43 * @param translation the translation
44 * @param angleXZ the angle around the XZ axis
45 * @param angleYZ the angle around the YZ axis
47 public Transform(final Point3D translation, final double angleXZ,
48 final double angleYZ) {
50 this.translation = translation;
51 orientation = new Orientation(angleXZ, angleYZ);
55 * Creates a new transform with the specified translation and orientation.
57 * @param translation the translation
58 * @param orientation the orientation
60 public Transform(final Point3D translation, final Orientation orientation) {
61 this.translation = translation;
62 this.orientation = orientation;
66 public Transform clone() {
67 return new Transform(translation, orientation);
70 public Orientation getOrientation() {
74 public Point3D getTranslation() {
79 * Applies this transform to the specified point in a 3D space.
81 * @param point to apply this transform to
83 public void transform(final Point3D point) {
84 orientation.rotate(point);
85 point.add(translation);