You are here

Writing Mathlets II: A Call to Math Professionals - Underlying Mathematics

Author(s): 
Tom Leathrum

The procedure for carrying out the projection from three dimensions to two begins by expressing the view vector as a unit vector \(u\) depending on the two view angles \(a\) and \(b\) by the formula

\(u=<\cos a \sin b,\sin a \sin b,\cos b>\)


Now, for a point \(P = (x_3,y_3,z_3)\) in space, take the vector \(v\) from the origin to \(P\), i.e. \(v = <x_3,y_3,z_3>\). Since \(u\) is a unit vector, the (linear algebra) projection of \(v\) onto \(u\) can be computed as proj\(_u v =(u \cdot v)u\) (the dot product of \(u\) and \(v\), scalar product with \(u\)). The vector given by \(v -\)proj\(_u v\) lies in the plane through the origin and perpendicular to \(u\). The head point \(Q\) of this vector has the useful property that the line through \(P\) and \(Q\) is perpendicular to that same plane (if \(P\) is not in the plane). Since the plane perpendicular to \(u\) is also parallel to the plane of the computer screen, this point \(Q\) can be interpreted as a point in a coordinate system on the computer screen.

The astute reader may realize that the key to the puzzle has just been mentioned: The plane perpendicular to the view vector \(u\) must have a coordinate system in order for \(Q\) to be interpreted in it. Even with the assumptions that the coordinate system in the plane will be orthonormal and right-handed, there is still the matter of rotation -- that is, rotation of the plane around the view vector \(u\). The view angles \(a\) and \(b\) uniquely determine the view vector \(u\), but say nothing about rotations around \(u\). This information must be determined some other way. In the applets above, the choice made was to eliminate this rotation by requiring that the projection of the point \((0,0,1)\) in space lie on the vertical axis in the plane -- i.e. \((0,0,1)\) projects to a point of the form \((0,k)\) in the plane.

This choice is admittedly a compromise, but it does simplify the computations tremendously. The formulas for projecting a point \((x_3,y_3,z_3)\) in space to a point \((x_2,y_2)\) in the plane, using the view angles \(a\) and \(b\), are

\(x_2 =-x_3 \sin a +y_3 \cos a\)

\(y_2 = -x_3 \cos a \cos b - y_3 \sin a \cos b + z_3 \sin b\)


In more advanced form, the problem can be stated by first noting that three real parameters are needed to describe all 3-by-3 orthogonal matrices with determinant +1, corresponding to transformations between orthonormal right-handed coordinate systems in space (graph rotations), but mouse motions in the applet can only supply horizontal and vertical data, filling in just two of these parameters.

Tom Leathrum, "Writing Mathlets II: A Call to Math Professionals - Underlying Mathematics," Convergence (November 2004)