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.
29 public Transform(final Point3D translation) {
30 this.translation = translation;
31 orientation = new Orientation();
35 * Creates a new transform with the specified translation and orientation.
40 * the angle around the XZ axis
42 * the angle around the YZ axis
44 public Transform(final Point3D translation, final double angleXZ,
45 final double angleYZ) {
47 this.translation = translation;
48 orientation = new Orientation(angleXZ, angleYZ);
52 * Creates a new transform with the specified translation and orientation.
59 public Transform(final Point3D translation, final Orientation orientation) {
60 this.translation = translation;
61 this.orientation = orientation;
65 public Transform clone() {
66 return new Transform(translation, orientation);
69 public Orientation getOrientation() {
73 public Point3D getTranslation() {
77 public void transform(final Point3D point) {
78 orientation.rotate(point);
79 point.add(translation);