PEXViewMappingMatrix Utility


Synopsis

 
   int PEXViewMappingMatrix(
       PEXCoord2D *frame,
       PEXNPCSubVolume *viewport,
       int perspective,
       PEXCoord *prp,
       double view_plane,
       double back_plane,
       double front_plane,
       PEXMatrix matrix_return
   )
 

Arguments

frame
Array of two 2D VRC locations which mark a rectangle in the view plane.

viewport
NPC viewport into which the frame gets mapped.

perspective
Flag to indicate whether a perspective view is desired, a value of True requests that perspective be applied.

prp
Projection reference point.

view_plane
VRC position of view plane with respect to the VRP.

back_plane
VRC position of the back plane with respect to the VRP.

front_plane
VRC position of the front plane with respect to the VRP.

matrix_return
Matrix into which result is stored.

Returns

Zero if successful; otherwise, one of the following:

PEXBadLimits
The viewing box depth, width or height is zero.

PEXBadViewport
xmin >= xmax, or ymin >= ymax, or zmin > zmax

PEXBadPlanes
View plane coordinates invalid.

PEXBadPRP
Projection reference point invalid.

Description

Invoke PEXViewMappingMatrix to create a view mapping matrix that transforms a volume specified in view reference coordinates (VRC) to a volume in normalized projection coordinates (NPC). This matrix is used in conjunction with a view orientation matrix as the viewing matrices for a designated view.

The axes of VRC form a right-handed coordinate system. The z axis is along the VPN (view plane normal, see PEXViewOrientationMatrix). THe y axis is fixed by VUP (view up vector, see PEXViewOrientationMatrix), and the x axis is determined so that the three axes form a right-handed coordinate system.

The front plane, back plane, and view plane all define planes in VRC parallel to the VRC x,y plane. The location of front_plane and back_plane along the z axis of VRC defines the front and back of the volume of VRC that is mapped to the specified NPC viewport. The view plane locates the view frame or "window" on the VRC z axis. The two points in frame determine the size of the view window by specifying lower left (frame[0]) and upper right (frame[1]) x and y VRC points of the window on the view plane. These values taken together establish the volume of VRC space that is mapped into the NPC viewport.

The type of projection may be parallel or perspective. The projection reference point (prp) orients the projectors defining the surfaces of the view volume. If perspective indicator is False, then the projection type is parallel and the projectors are all parallel to the vector joining the projection reference point and the center of the view window (located on the view plane). If perspective is True, then the projectors all converge at the projection reference point. Thus, the view volume is a parallelpiped for parallel views, and a truncated pyramid for perspective views.

When specifying NPC, the x, y and z limits must be as follows:

xmin < xmax, ymin < ymax, zmin <= zmax

Errors

None.

See Also

For a list of viewing transformation utilities, see Viewing Transformation Utilities. For a list of related topics, see PEXlib Utilities.