Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

concat_matrix(3G)

concat_transformation(3G)

gopen(3G)

mapping_mode(3G)

push_matrix(3G)

pop_matrix(3G)

push_vdc_matrix(3G)

set_p1_p2(3G)

vdc_extent(3G)

view_matrix(3G)

vdc_justification(3G)

REPLACE_MATRIX(3G)

NAME

replace_matrix − replace current transformation matrix with a specified matrix

SYNOPSIS

C Syntax:

void replace_matrix2d(fildes,xform2);
int fildes;
float xform2[3][2];

void replace_matrix3d(fildes,xform3);
int fildes;
float xform3[4][4];

FORTRAN77 Syntax:

See Language Dependencies Below

subroutine replace_matrix2d(fildes,xform2)
integer*4 fildes
real xform2(2,3)

subroutine replace_matrix3d(fildes,xform3)
integer*4 fildes
real xform3(4,4)

Pascal Syntax:

type
two_d_xform = array [1..3][1..2] of real;
three_d_xform = array [1..4][1..4] of real;

procedure replace_matrix2d(fildes:integer;
var xform2:two_d_xform);

procedure replace_matrix3d(fildes:integer;
var xform3:three_d_xform);

DESCRIPTION

Input Parameter

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

xform2 A 3x2 2-dimensional matrix. 

xform3 A 4x4 3-dimensional matrix. 

Discussion

The current transformation matrix (top of matrix stack) is replaced by the specified matrix, xform2 or xform3.  If the graphics device has not been opened in MODEL_XFORM mode, the matrix is concatenated with the current viewing transformation matrix before the replacement is made.  The current transformation matrix is used to transform subsequent output primitives. 
 
The vdc-to-device units-transformation matrix cannot be replaced using replace_matrix2d or replace_matrix3d. It can be changed using vdc_extent, vdc_justification, set_p1_p2, or mapping_mode. Likewise, the viewing transformation matrix cannot be replaced using these functions.  It can be changed using view_camera, view_matrix, view_volume, or view_window. If there are no matrices in the matrix stack, replace_matrix generates a warning. 

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

It is assumed that user points are defined in modeling coordinates.  These points are transformed into world coordinates using a matrix called the modeling transformation matrix (provided a matrix has been pushed on the stack).  World coordinates are used to perform any rendering calculations needed. 

World coordinates are then 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 consists of the vdc-to-device coordinate transformation matrix.  Viewing functions can be used to define further viewing transformations such as perspective. 

Use replace_matrix to place modeling transformations on the matrix stack.  If a graphics device has been opened in MODEL_XFORM mode, special rendering calculations such as shading may be needed after the modeling-to-world coordinate transformation.  For this reason, the modeling transformation cannot be combined with the viewing transformation.  Thus, matrices pushed on the stack are left as is and all transformations from modeling coordinates to device coordinates occur in two steps:  modeling to world coordinates followed by world-to-device coordinates. 

If a graphics device is not in MODEL_XFORM mode then the modeling and viewing transformations may 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 by the top matrix on the matrix stack only. 

Starbase maintains all matrices in 3-dimensional (4x4) form, so replace_matrix2d must expand the matrix xform2. 

Perspective transformations (as well as any other non-linear or viewing transformation) should not appear in modeling matrices since this will distort surface normals, invalidating lighting calculations; rather, they should appear in the viewing transformation which is set with view_matrix. When performing perspective transformations, a perspective model where the eye is at origin of perspective space is recommended.  Any other model can easily be modified by a single translation step.

LANGUAGE DEPENDENCIES

FORTRAN77:
A transposition of array rows and columns is required due to the manner in which FORTRAN77 stores arrays. 

DEFAULTS

After gopen, the current transformation matrix is the vdc-to-device units transformation matrix.

SEE ALSO

concat_matrix(3G), concat_transformation(3G), gopen(3G), mapping_mode(3G), push_matrix(3G), pop_matrix(3G), push_vdc_matrix(3G), set_p1_p2(3G), vdc_extent(3G), view_matrix(3G), vdc_justification(3G). 

Hewlett-Packard Company  —  May 11, 2021

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