More Grid Lines

Ok, I think I’ve determined how to get the Xmin,Xmax,Ymin,Ymax of the world coordinate system for grid generation. There are three conditions.

  1. The xy plane does not pass thru the viewing frustum.
  2. The xy plane is co-planar with one of the clipping planes of the frustum
  3. The xy plane passes thru the viewing frustum which means the xy plane intersects at least three of the intersections between two clipping planes. I hope that makes sense.

The method:

  1. Construct 12 vectors representing the intersections of 2 clipping planes. For example one vector might represent the intersection of the far and top planes.
  2. Determine which vectors are coplanar with the model coordinate system xy plane. If enough vectors are coplanar use those vectors to set up the grid XY values and go to step 4.
  3. Determine if and where the 12 vectors intersect the model coordinate system xy plane. Use the intersection points to set up grid XY values.
  4. draw grid.

Questions:

  1. To get the normal of the model coordinate system I just need to multiply the vector (0,0,1) times the model transform matrix, right? Should I then normalize the result?
  2. To determine if a vector is coplanar with the xy plane I need to check that the dot product of the xy plane normal and the vector in question is zero, right?
  3. What calculation do I perform to determine if one of the 12 vectors intersects the model xy plane and where?

What do you think? Will this work?

  1. Does a coordinate system have a normal?
  2. Yes, that is one way. You have
    v1.v2 = |v1| |v2| * cos(a)
    so if both |v1| and |v2| is not zero must cos(a) be zero.
  3. I think that you better search the net for this one since you will find a lot. An option could be to use a library that has similar functions.

About your first question. Multiplying the vector (0,0,1) with the rotation matrix will show you how that vector is rotated. If the normal was pointing at (0,0,1) will the result be how the normal is pointing after the rotation.
If your rotation matrix does not scale do you not have to normalise if the vector has unit length.