Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

concat_matrix(3G)

concat_transformation(3G)

flush_matrices(3G)

gopen(3G)

pop_matrix(3G)

push_matrix(3G)

replace_matrix(3G)

view_matrix(3G)

TRANSFORM_POINT(3G)

NAME

transform_point, transform_points − transform a point or points from one coordinate system to another

SYNOPSIS

C Syntax:

void transform_point(fildes,mode,inx,iny,inz,outx,outy,outz);
int fildes,mode;
float inx,iny,inx,*outx,*outy,*outz;

void transform_points(fildes,wc_pts,dc_pts,
numpts,homogeneous)
int fildes,numpts,homogeneous;
float wc_pts[],dc_pts[];

FORTRAN77 Syntax:

subroutine transform_point(fildes,mode,inx,iny,inz,outx,outy,outz)
integer*4 fildes,mode
real inx,iny,inz,outx,outy,outz

subroutine transform_points(fildes,wc_pts,
dc_pts,num_pts,homogeneous)
integer*4 fildes,numpts,homogeneous
real wc_pts(numpts*3),dc_pts(numpts*3)

Pascal Syntax:

procedure transform_point(fildes,mode:integer;inx,iny,inz:real;
var outx,outy,outz:real);

procedure transform_points(fildes:integer;
var wc_pts,dc_pts:array[lo..hi:integer]of real;
numpts,homogeneous:integer);

DESCRIPTION

Input Parameters

fildes Integer file descriptor returned by gopen when an I/O path to a graphics device is opened. 

mode Defines the transformation to be made (transform_point):

MC_TO_WORLD
transform from modeling coordinates to world coordinates.

MC_TO_VDC transform from modeling coordinates to virtual device coordinates. 

WORLD_TO_VDC
transform from world coordinates to virtual device coordinates.

WORLD_TO_MC
transform from world coordinates to modeling coordinates.

VDC_TO_WORLD
transform from virtual device coordinates to world coordinates.

VDC_TO_MC transform from virtual device coordinates to modeling coordinates. 

inx,iny,inz Point to be transformed (transform_point).

wc_pts Array of world-coordinate points to be transformed (transform_points).

num_pts Number of points to be transformed (transform_points).

homogeneous TRUE if the wc_pts array contains homogeneous coordinates (transform_points).

Output Parameters

outx,outy,outz Transformed point (transform_point).

dc_pts Array of transformed points in device coordinates (transform_points).

Discussion: transform_point

Transform_point transforms a single point from one coordinate system to anohter, using the current set of transformation matrices.  Transform_point left-multiplies a coordinate vector made up of inx,iny,inz with the appropriate transformation matrix, as specified by mode, and returns the resulting transformed point in the coordinate vector made up of outx,outy,outz. 

The coordinate systems used by Starbase can be conceptually defined as follows:

• User points are assumed to be defined in modeling coordinates.  These points are transformed into world coordinates using a matrix called the modeling transformation matrix (if any matrices have been pushed on the stack).  World coordinates are used to perform any rendering calculations needed. 

• Next, the world coordinates are transformed to device coordinates by the viewing transformation matrix, which is usually the concatenation of user-defined viewing transformations and the vdc-to-device transformation matrix.  When a device is opened, the viewing transformation matrix is simply the vdc-to-device coordinate transformation matrix.  view_matrix can be used to define further viewing transformations such as perspective. 

Use matrix stack manipulation functions to place modeling transformation matrices on the matrix stack.  Use view_matrix to set viewing transformations. 

• If a graphics device has been opened in MODEL_XFORM mode, the modeling transformation cannot be combined with the viewing transformation because special rendering calculations such as shading may be needed after the modeling-to-world-coordinate transformation.  Therefore, matrices pushed on the stack are left undisturbed and all transformations from modeling coordinates to device coordinates are processed in two steps:  modeling to world coordinates, followed by world to device coordinates. 

• If a graphics device is not in MODEL_XFORM mode, the modeling and viewing transformations can be combined.  Thus, the current viewing transformation matrix is post-concatenated to modeling matrices placed on the matrix stack, and subsequent output primitives are transformed, using only the top matrix on the matrix stack. 

transform_point calculates matrix inverses only if a given transformation matrix has been changed since its inverse was last calculated.  If in MODEL_XFORM mode, inverses are needed to perform the following transformations: WORLD_TO_MC, VDC_TO_WORLD, and VDC_TO_MC.  If not in MODEL_XFORM mode, inverses are needed for the cases listed above, as well as MC_TO_WORLD. 

Discussion: transform_points

Transform_points transforms an array of points, wc_pts, using the top matrix on the matrix stack to calculate transformed coordinate point values.  The results are placed in array dc_pts.  If the homogeneous (perspective) coordinate is zero, the data is three dimensional with 3 coordinates per point.  Since Starbase uses (4 x 4) transformation matrices internally, a homogeneous coordinate value of 1 is assigned to points when the user supplies only 3 coordinates per point.  If the homogeneous (perspective) coordinate is non-zero, there are 4 coordinates per point with the fourth being the homogeneous coordinate.  Returned points, however, always have 4 coordinates per point.  No perspective divide is performed.  This function makes use of the floating-point hardware in the device, if present, and can be used for generalized (n x 4) * (4 x 4) transformations.  If the device does not have floating point hardware and the device has been gopened in the 2D mode, the homogeneous coordinate is ignored. 

Note that if the graphics device has been opened in MODEL_XFORM mode, the top matrix on the matrix stack is the modeling-to-world coordinate transformation.  If modeling matrices have been pushed on the stack, the points will be transformed through the current modeling matrix only; not the viewing matrix.  If the graphics device is not in MODEL_XFORM mode then the top matrix on the matrix stack is the concatenation of the modeling transformation with the viewing transformation and vdc-to-device matrix.  Thus, points are transformed from modeling coordinates to device coordinates. 

SEE ALSO

concat_matrix(3G), concat_transformation(3G), flush_matrices(3G), gopen(3G),
pop_matrix(3G), push_matrix(3G), replace_matrix(3G), view_matrix(3G),
Starbase Graphics Techniques.

Hewlett-Packard Company  —  May 11, 2021

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026