| 13 | import org.opensourcephysics.numerics.VectorMath; |
| 14 | |
| 15 | public class Camera implements org.opensourcephysics.display3d.core.Camera { |
| 16 | static private final double ratioToScreen = 2.5, ratioToFocus = 2.0; |
| 17 | static private final double[] vertical = {0, 0, 1}; |
| 18 | static final int CHANGE_ANY = 0; |
| 19 | static final int CHANGE_MODE = 1; |
| 20 | static final int CHANGE_POSITION = 2; |
| 21 | static final int CHANGE_FOCUS = 3; |
| 22 | static final int CHANGE_ROTATION = 4; |
| 23 | static final int CHANGE_SCREEN = 5; |
| 24 | static final int CHANGE_ANGLES = 6; |
| 25 | // Configuration variables |
| 26 | private int projectionMode = org.opensourcephysics.display3d.core.Camera.MODE_PERSPECTIVE; |
| 27 | private double posX, posY, posZ; |
| 28 | private double focusX, focusY, focusZ; |
| 29 | private double distanceToScreen, rotationAngle = 0; |
| 30 | private double alpha = 0.0, beta = 0.0; |
| 31 | // Implementation variables |
| 32 | private double distanceToFocus, panelMaxSizeConstant; |
| 33 | double cosAlpha = 1, sinAlpha = 0, cosBeta = 1, sinBeta = 0; |
| 34 | private double cosRot = 1, sinRot = 0; |
| 35 | private double[] e1, e2, e3; |
| 36 | private Projection projection = new Projection(); |
| 37 | private Quaternion rotation = new Quaternion(1, 0, 0, 0); |
| 38 | |
| 39 | /** |
| 40 | * The DrawingPanel3D to which it belongs. |
| 41 | * This is needed to report to it any change that implies a call to update() |
| 42 | */ |
| 43 | private DrawingPanel3D panel; |
| 44 | |
| 45 | Camera(DrawingPanel3D aPanel) { |
| 46 | this.panel = aPanel; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Only for the use of the XMLLoader for DrawingPanel3D! |
| 51 | * Sets the panel of this camera |
| 52 | * @param aPanel DrawingPanel3D |
| 53 | */ |
| 54 | void setPanel(DrawingPanel3D aPanel) { |
| 55 | this.panel = aPanel; |
| 56 | } |
| 57 | |
| 58 | // ----------------------------- |
| 59 | // Implementation of Camera |
| 60 | // ---------------------------- |
| 61 | @Override |
| 62 | public void setProjectionMode(int mode) { |
| 63 | projectionMode = mode; |
| 64 | if(panel!=null) { |
| 65 | panelMaxSizeConstant = panel.getMaximum3DSize()*0.01; |
| 66 | panel.cameraChanged(CHANGE_MODE); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | final public int getProjectionMode() { |
| 72 | return projectionMode; |
nothing calls this directly
no outgoing calls
no test coverage detected