Re: 3D ProjectionControl matrix & point of view

Hi Stuart,

> Where is there a description of the ProjectionControl matrix?

These are the Java3D matrices, so we leave it to their
semi-inscrutible documentation (and the Java2D matrices
for DisplayImplJ2D).  However, see below.

> And if someone already knows the answer to this particular
> question, please let me know.
> What values are used in the ProjectionControl matrix
> to switch a 3D display to a view from on top, and from south, north,
> east, and west?
> 
> Alternately, what values are used in:
> 
> /** create a projection matrix appropriate for this graphics API
>       from x, Y and Z rotation angles, from a scale factor, and from
>       X, Y and Z translation amounts;
>       these creates the matrix format used by the getMatrix and
>       setMatrix methods of ProjectionControl */
>   public double[] make_matrix(double rotx, double roty, double rotz,
>                               double scale, double transx,
>                               double transy, double transz);
> 
> to create these points of view?
> 
> Are any of these angles (rotx etc.) equivalent to azimuth (view from an angle
> measured
> from north 0 to 360) and elevation (something like 90 = from overhead
> and 0 = from side)?

Like a lot of VisAD code, make_matrix is borrowed from Vis5D,
which also includes the following function that should solve
your problem:

/*
 * Set the view to either North, South, East, West, Top, or Bottom.
 * Input:  view - one of VIS5D_NORTH, VIS5D_SOUTH, .. VIS5D_BOTTOM
 */
vis5d_set_ortho_view( int index, int view )
{
  MATRIX ctm;
  CONTEXT("vis5d_ortho_view")

   switch (view) {
      case VIS5D_BOTTOM:
         make_matrix( 0.0, 180.0, 0.0, 1.0, 0.0, 0.0, 0.0, ctm );
         vis5d_set_matrix(index, ctm);
         break;
      case VIS5D_NORTH:
         make_matrix( -90.0, 180.0, 0.0, 1.0, 0.0, 0.0, 0.0, ctm );
         vis5d_set_matrix(index, ctm);
         break;
      case VIS5D_EAST:
         make_matrix( -90.0, -90.0, 0.0, 1.0, 0.0, 0.0, 0.0, ctm );
         vis5d_set_matrix(index, ctm);
         break;
      case VIS5D_TOP:
         make_matrix( 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, ctm );
         vis5d_set_matrix(index, ctm);
         break;
      case VIS5D_SOUTH:
         make_matrix( -90.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, ctm );
         vis5d_set_matrix(index, ctm);
         break;
      case VIS5D_WEST:
         make_matrix( -90.0, 90.0, 0.0, 1.0, 0.0, 0.0, 0.0, ctm );
         vis5d_set_matrix(index, ctm);
      default:
         return VIS5D_BAD_CONSTANT;
   }
. . .

You can just ignore the extra ctm parameter, which substitutes
for the object reference.

However, there may be differences between the Java3D matrices used
in VisAD and the OpenGL matrices used in Vis5D (e.g., transpose).
If the make_matrix parameters from vis5d_set_ortho_view() don't
work quite right, it may only be a matter of permuting them a bit.
This should not be all that hard to do with a little experimentation.
Let me know if you need a little help.

Once this is working it would be very useful to add a set_ortho_view()
method to ProjectionControlJ3D or MouseBehaviorJ3D.

Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html