2 * Sixth 3D engine. Copyright ©2012-2019, 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.math;
13 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
15 public class Orientation implements Cloneable {
17 private double s1, c1, s2, c2;
19 private double angleXZ = 0;
20 private double angleYZ = 0;
22 public Orientation() {
26 public Orientation(final double angleXZ, final double angleYZ) {
27 this.angleXZ = angleXZ;
28 this.angleYZ = angleYZ;
33 public Orientation clone() {
34 return new Orientation(angleXZ, angleYZ);
37 private void computeMultipliers() {
38 s1 = Math.sin(angleXZ);
39 c1 = Math.cos(angleXZ);
41 s2 = Math.sin(angleYZ);
42 c2 = Math.cos(angleYZ);
45 public void rotate(final Point3D point3d) {
46 final double z1 = (point3d.z * c1) - (point3d.x * s1);
47 point3d.x = (point3d.z * s1) + (point3d.x * c1);
49 point3d.z = (z1 * c2) - (point3d.y * s2);
50 point3d.y = (z1 * s2) + (point3d.y * c2);
53 public void rotate(final double angleXZ, final double angleYZ) {
54 this.angleXZ += angleXZ;
55 this.angleYZ += angleYZ;