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

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

SYNOPSIS

C Syntax:

void inttransform_point2d(fildes,mode,inx,iny,outx,outy);
int fildes,mode,inx,iny,*outx,*outy;

void transform_point(fildes,mode,inx,iny,inz,outx,outy,outz);
int fildes,mode;
float inx,iny,inz,*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 inttransform_point2d(fildes,mode,inx,iny,outx,outy)
integer∗4 fildes,mode,inx,iny,outx,outy

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∗4)
or real wc_pts(numpts∗4),dc_pts(numpts∗4)

Pascal Syntax:

procedure inttransform_point2d(fildes,mode,inx,iny:integer;
var outx,outy:integer);

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 modelling coordinates to world coordinates.

MC_TO_VDC transform from modelling coordinates to virtual device coordinates. 

WORLD_TO_VDC
transform from world coordinates to virtual device coordinates.

WORLD_TO_MC
transform from world coordinates to modelling coordinates.

VDC_TO_WORLD
transform from virtual device coordinates to world coordinates.

VDC_TO_MC transform from virtual device coordinates to modelling coordinates. 

INTVDC_TO_DC
transform from virtual device coordinates to device coordinates.

DC_TO_INTVDC
transform from device coordinates to virtual device 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 and inttransform_point2d transform a single point from one coordinate system to another, using the current set of transformation matrices.  Transform_point and inttransform_point2d left-multiply a coordinate vector made up of inx,iny,inz or inx,iny 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 or outx,outy. 

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

1.  User points are assumed to be defined in modelling coordinates.  These points are transformed into world coordinates using a matrix called the modelling transformation matrix if any matrices have been pushed on the stack.  World coordinates are used to perform any rendering calculations needed.  Use matrix stack manipulation functions to place modelling transformation matrices on the matrix stack. 

2.  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.  Intview_window, intview_port, intview_matrix2d, view_window, view_port, view_volume, view_camera, and view_matrix can be used to define further viewing transformations. 

Use matrix stack manipulation functions to place modelling 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 modelling transformation cannot be combined with the viewing transformation because special rendering calculations such as shading may be needed after the modelling-to-world-coordinate transformation.  Therefore, matrices pushed on the stack are left undisturbed and all transformations from modelling coordinates to device coordinates are processed in two steps:  modelling to world coordinates, followed by world to device coordinates. 

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

Transform_point and inttransform_point2d 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. 

Actually, the current viewing transformation matrix is post-concatenated to modelling matrices placed on the matrix stack, and subsequent output primitives are transformed, using only the top matrix on the matrix stack. 

Integer operations are only available when using the INT_XFORM gopen mode. When in INT_XFORM mode, floating point operations are not available for that fildes. Floating point operations are the default, or can be specified with FLOAT_XFORM mode. For a list of integer operations, floating point operations and common operations see the starbase.3g manual page. 

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 modelling-to-world coordinate transformation.  If modelling matrices have been pushed on the stack, the points will be transformed through the current modelling 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 modelling transformation with the viewing transformation and vdc-to-device matrix.  Thus, points are transformed from modelling coordinates to device coordinates. 

NOTE

When using inttransform_point2d to transform points between coordinate systems with large resolution differences, some precision may be lost during intermediate transformations. For example, the transformation from world coordinates to virtual device coordinates uses intermediate values in the device coordinate system. The precision of the virtual device coordinates result is therefore dependent on the coordinate system with the least resolution. 

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