2 * Sixth - System for data storage, computation, exploration and interaction.
3 * Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 3 of the GNU Lesser General Public License
7 * or later as published by the Free Software Foundation.
11 package eu.svjatoslav.sixth.e3d.gui;
13 import eu.svjatoslav.sixth.e3d.geometry.GeometryCoordinate;
14 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
15 import eu.svjatoslav.sixth.e3d.geometry.TransformPipe;
17 public class UserRelativityTracker {
19 public final static int minimalSliceFactor = 5;
20 public GeometryCoordinate center = new GeometryCoordinate();
21 public GeometryCoordinate right;
22 public GeometryCoordinate down;
24 public UserRelativityTracker() {
28 public void analyze(final TransformPipe transformPipe,
29 final RenderingContext renderingContext) {
31 center.transform(transformPipe, renderingContext);
34 right.transform(transformPipe, renderingContext);
35 down.transform(transformPipe, renderingContext);
39 public void enableOrientationTracking() {
40 right = new GeometryCoordinate(new Point3D(10, 0, 0));
41 down = new GeometryCoordinate(new Point3D(0, 10, 0));
44 public double getAngleXY() {
45 return center.transformedCoordinate
46 .getAngleXY(down.transformedCoordinate);
49 public double getAngleXZ() {
50 return center.transformedCoordinate
51 .getAngleXZ(right.transformedCoordinate);
54 public double getAngleYZ() {
55 return center.transformedCoordinate
56 .getAngleYZ(down.transformedCoordinate);
59 public double getDistanceToUser() {
60 return center.transformedCoordinate
61 .getDistanceTo(Point3D.ZERO);
64 public double proposeSliceFactor() {
65 final double distanceToCamera = getDistanceToUser();
67 double proposedSliceFactor = distanceToCamera / 5;
69 if (proposedSliceFactor < minimalSliceFactor)
70 proposedSliceFactor = minimalSliceFactor;
72 return proposedSliceFactor;