provided by: 
Originally published at Internet.comJava Programming Notes # 1548 * Preface * General * Viewing tip * Figures * Listings * Supplementary material * General background information * Preview * The program named Java3D008 * The program named Java3D009 * Discussion and sample code * The program named Java3D008 * The program named Java3D009 * Run the programs * Summary * What's next? * Download * Resources * Complete program listings * Copyright * About the author -----------------------------------
Preface
General
Fifth in a series of lessons
This is the fifth lesson in a series of lessons designed to start with Java 3D basics and work up to some very complicated programs, such as the program that I explained in the earlier lesson titled "Understanding Lighting in the Java 3D API" (see Resources).
The first lesson in this series was titled "Back to Basics in the Java 3D API" (see Resources). The previous lesson was titled "Understanding the Alpha Time-Base Class in Java 3D." This lesson is titled "Combining Rotation and Translation in Java 3d." My current plan is for future lessons to deal with user and object interaction as well as advanced animation and textures.
What you will learn
Understanding rotation in Java 3D is not too difficult. Similarly, it is not too difficult to understand translation in Java 3D. However, when you combine rotation with translation, things become very complicated very quickly. If you don't really understand what you are doing when you combine the two, the chance that you will get it right the first time is probably less than fifty percent. In this lesson, I will teach you how to get it right the first time by helping you to understand the impact of the order of rotation and translation on the behavior of the program.
Compiling and running Java 3D programs
In order to compile and run programs using the Java 3D API, you will need to download and install the Java 3D API software. As of the date of this writing, version 1.5.0 is available for download.
In addition, you will need to download and install either Microsoft DirectX or OpenGL. All of the sample programs in this series of tutorials were developed and tested using Microsoft DirectX. They were not tested using OpenGL.
Viewing tip
I recommend that you open another copy of this document in a separate browser window and use the following links to easily find and view the figures and listings while you are reading about them.
Figures
* Figure 1. A view of the universe along with the user input GUI. * Figurre 2. Another screen shot of the program named Java3D008. * Figure 3. White sphere rotating about its own tilted vertical axis. * Figure 4. White sphere orbiting yellow sphere in a tilted plane.
Listings
* Listing 1. Constructor for the top-level class. * Listing 2. Beginning of the class named TheScene. * Listing 3. Beginning of the constructor for the class named TheScene. * Listing 4. Beginning of code used to animate the universe. * Listing 5. Beginning of code to animate the white sphere. * Listing 6. The method named rotate. * Listing 7. The method named translate. * Listing 8. Code that is executed when the user clicks the "b" button. * Listing 9. Code that is executed when the user clicks the "c" button. * Listing 10. Complete the constructor for the class named TheScene. * Listing 11. Code that is executed when the user clicks the "a" button. * Listing 12. The method named tiltTheAxes. * Listing 13. Code that is executed when the user clicks the "b" button. * Listing 14. Code that is executed when the user clicks the "c" button. * Listing 15. Program listing for the program named Java3D008. * Listing 16. Program listing for the program named Java3D009.
Supplementary material
I recommend that you also study the other lessons in my extensive collection of online Java tutorials. You will find a consolidated index at www.DickBaldwin.com.
General background information
Rotation and translation are two of several different types of transforms that you can apply to objects in Java 3D, including: * scaling * translation * shear * rotation
I explained some of these transforms as they apply in the 2D world in the earlier lesson titled "Java 2D Graphics, Simple Affine Transforms" (see Resources). I will deal with translation and rotation in Java 3D in this lesson, and will deal with scaling and shear in future lessons.
Preview
The program named Java3D008
In this lesson, I will present and explain two programs. The first program is named Java3D008. The purpose of this program is to illustrate the behavior imparted by the order of rotation and translation when used together.
The universe
The universe contains a yellow sphere, a green sphere, and a white sphere as shown by the left image in Figure 1.
Figure 1. A view of the universe along with the user input GUI.
Figure 1 also shows the user input GUI on the right.
Behavior of the yellow sphere
The yellow sphere slowly rotates around the vertical axis in 3D space for a specified period of time. The center of the yellow sphere
Author: Richard G. Baldwin
Read article at Internet.com site