/** * Sets the view angle. */ public void setView(double theta, double phi) { this.theta = theta; this.phi = phi; precompute(); reset(); }
/** * Rotate the 3D view based on the changes on mouse position. * @param x changes of mouse position on the x axis. * @param y changes on mouse position on the y axis. */ public void rotate(double x, double y) { if (!(projection instanceof Projection3D)) { throw new UnsupportedOperationException("Only 3D graphics supports rotation."); } ((Projection3D) projection).rotate(x, y); } }
/** * Sets the default view angle. */ public void setDefaultView() { setView(Math.PI / 4, Math.PI / 8); }
/** * Initialize the Graphics object. */ private void initGraphics() { if (base.dimension == 2) { graphics = new Graphics(new Projection2D(this)); } else { graphics = new Graphics(new Projection3D(this)); } }
/** * Resets the plot. */ public void reset() { base.reset(); graphics.projection.reset(); baseGrid.setBase(base); if (graphics.projection instanceof Projection3D) { ((Projection3D) graphics.projection).setDefaultView(); } canvas.repaint(); }
zc[i][j] = p3d.z(data[i][j]);
/** * Rotates the plot, i.e. change the view angle. * @param t the change add to θ * @param p the change add to φ */ public void rotate(double t, double p) { theta = theta - t / 100; phi = phi + p / 100; precompute(); reset(); } }