PEXLookAtViewMatrix Utility


Synopsis

 
   int PEXLookAtViewMatrix(
       PEXCoord *from,
       PEXCoord *to,
       PEXVector *up,
       PEXMatrix matrix_return
   )
 

Arguments

from
Viewing position, in world coordinates.

to
Look at position, in world coordinates.

up
Vector representing the up direction, in world coordinates.

matrix_return
Matrix in which result is stored.

Returns

Zero if successful; otherwise, one of the following:

PEXBadVectors
The from and to arguments are equal, or the line between them is parallel with the up vector.

PEXBadVector
Up is zero length.

Description

Invoke PEXLookAtViewMatrix to create a view orientation transform that defines the viewing direction and orientation. This utility is a slightly more intuitive interface to PEXViewOrientationMatrix.

The from position defines the viewpoint, and the to position specifies the point being viewed. These two arguments together define the view reference point (the VRC origin) and the view plane normal of PEXViewOrientationMatrix. The view reference point is the to point; the view plane normal is the vector from to to from.

The view up vector is a 3D vector defined in world coordinates relative to the to point. The projection of this vector onto the plane through the to point and perpendicular to the view plane normal defines the y axis of VRC.

Errors

None.

See Also

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