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
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:
Calculus applets in Java: 4 applets which were developed for
Howard Anton's Calculus textbook, from John Wiley & Sons.
NASA Voyager images in Java: A paper about using Client-side CGI for processing spacecraft images.
Java vs. C++ speed tests: Some simple matrix operations to test the execution speed of Java and C++.
Polynomial curve fitting in Java. This application fits an nth-order polynomial to a set of data.
This was originally developed under MSJ++ for W95, so the window layouts are a little off.
N-body gravitational motion in Java. This application simulates the 3d orbital motion of masses using gravity
and a 4th-order Runge-Kutta integration method. This was originally developed under MSJ++ for W95, so the window layouts are a little off.
© Copyright Sky Coyote, 1996-2003.