Some Java Examples

Example 7: 3-d surface and sliders.

Here's an applet that draws a 3d set of axes, and a wireframe surface about the axes. You can rotate and zoom the axes and surface with the mouse. You can recompute and redisplay the surface with a set of sliders.

Run the example

The applet displays the following surface:

  z = amp * sin(fx * x) * cos(fy * y)
Drag the mouse to rotate the axes. Hold down the shift key and drag away from or toward the center to zoom in or out. Drag the sliders to recompute and redisplay the surface, based on new values for amp, fx, and fy.

Look at the code

Click here to see the Java source code for the applet. I recommend that you download the code and run it under Applet Viewer or something, especially if you don't have a Java capable browser to see it here, or if it doesn't look right in your browser.

In addition to the 3d drawing, this applet demonstrates threads and slider UI. Note the use of synchronized threads for computing the data and displaying the data. The slider type can probably be abstracted out into its own class for use in other applets. Feel free to steal the code for your own applications.

Other Java applets/applications:

© Copyright Sky Coyote, 1996-2003.