Mathematics Behind the Applet - Simple Rotation

All formulas that we use in the code follow from the 3D change of coordinates and projection formulas that we derived in Simple 3D Drawing in Flash CS3 - Mathematics Behind Rotation, Projection and Depth Sorting. However, the situation is much simpler here. We are still in the same basic xyz-space and we move the observer, but instead of having a solid to look at we have a flat rectangle with an image on each side. The rectangle is located on the yz-plane. Only the horizontal angle, theta, of the observer changes. The vertical displacement angle, phi, does not change and remains at 90 degrees. Here is the initial position:

Now the observer moves horizonatlly by the angle theta. Recal that in our 3D engine, we consider a new coordinate system, newx, newy, newz, in which the observer remains on the x-axis. Since the displacement in our case is only horizontal the new coordinate system looks as follows:

The new 'view plane' - the plane perpendicular to the new x axis - is marked in green. A portion of the rectangle is behind the plane, a portion is in front of it. Recall that we create a new view of our object by calculating the coordinates of its vertices in the new coordinate system and then projecting it onto the new view plane. In our particular situation, those formulas simplify greatly. A point on the yz-plane,
P=[0,py,pz] in the original coordinate system, has the following coordinates in the new coordinate system. (Our vertices are located originally on the yz-plane so px=0.)

How about the projection of the point [pnewx,pnewy,pnewz] onto the view plane? This is where mathematically the difference is small but from the point of view of manipulating bitmaps the difference is huge. We discuss the issue on the next page.

Download

This is the same applet file as on the front page. We include a link on every page for your convenience.

Back to Advanced and Experimental              Back to Flash and Math Home

The site www.flashandmath.com is maintained by Doug Ensley (doug@flashandmath.com) and Barbara Kaskosz (barbara@flashandmath.com).
It has been developed with partial funding from the National Science Foundation and the Mathematical Association of America.