2 * Sixth 3D engine. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
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.
11 package eu.svjatoslav.sixth.e3d.geometry;
13 public class Orientation implements Cloneable {
15 private double s1, c1, s2, c2;
17 private double angleXZ = 0;
18 private double angleYZ = 0;
20 public Orientation() {
24 public Orientation(final double angleXZ, final double angleYZ) {
25 this.angleXZ = angleXZ;
26 this.angleYZ = angleYZ;
31 public Orientation clone() {
32 return new Orientation(angleXZ, angleYZ);
35 private void computeMultipliers() {
36 s1 = Math.sin(angleXZ);
37 c1 = Math.cos(angleXZ);
39 s2 = Math.sin(angleYZ);
40 c2 = Math.cos(angleYZ);
43 public void rotate(final Point3D point3d) {
44 final double z1 = (point3d.z * c1) - (point3d.x * s1);
45 point3d.x = (point3d.z * s1) + (point3d.x * c1);
47 point3d.z = (z1 * c2) - (point3d.y * s2);
48 point3d.y = (z1 * s2) + (point3d.y * c2);
51 public void rotate(final double angleXZ, final double angleYZ) {
52 this.angleXZ += angleXZ;
53 this.angleYZ += angleYZ;