##
T3D

The
T3D procedure implements three-dimensional
transforms.

This routine accumulates one or more sequences of
translation,
scaling,
rotation,
perspective, and oblique transformations and stores the result in
!P.T, the 3D transformation system variable. All the IDL graphic routines use this (4,4) matrix for output. Note that !P.T3D is *
not*
set, so for the transformations to have effect you must set !P.T3D = 1 (or set the T3D keyword in subsequent calls to graphics routines).

This procedure is based on that of Foley & Van Dam, *
Fundamentals of Interactive Computer Graphics*
, Chapter 8, "Viewing in Three Dimensions". The matrix notation is reversed from the normal IDL sense, i.e., here, the first subscript is the column, the second is the row, in order to conform with this reference.

A right-handed system is used. Positive rotations are counterclockwise when looking from a positive axis position towards the origin.

This routine is written in the IDL language. Its source code can be found in the file ```
t3d.pro
```

in the ```
lib
```

subdirectory of the IDL distribution.

###
Keywords

Any, all, or none of the following keywords can be present in a call to T3D. The order of the input parameters does not matter.

The transformation specified by each keyword is performed in the order of their descriptions below (e.g., if both TRANSLATE and SCALE are specified, the translation is done first).

####
OBLIQUE

A two-element vector of oblique projection parameters. Points are projected onto the XY plane at Z=0 as follows:

x' = x + z(d * COS(a))

y' = y + z(d * SIN(a))

where OBLIQUE[0] = d and OBLIQUE[1] = a.

####
PERSPECTIVE

Perspective transformation. This parameter is a scalar (p) that indicates the Z distance of the center of the projection. Objects are projected into the XY plane at Z=0, and the "eye" is at point (0,0,p).

####
RESET

Set this keyword to reset the transformation to the default identity matrix.

####
ROTATE

A three-element vector of the rotations, in DEGREES, about the X, Y, and Z axes. Rotations are performed in the order of X, Y, and then Z.

####
SCALE

A three-element vector of scale factors for the X, Y, and Z axes.

####
TRANSLATE

A three-element vector of the translations in the X, Y, and Z directions.

####
XYEXCH

Set this keyword to exchange the X and Y axes.

####
XZEXCH

Set this keyword to exchange the X and Z axes.

####
YZEXCH

Set this keyword to exchange the Y and Z axes.

###
Examples

To reset the transformation, rotate 30 degs about the X axis and do perspective transformation with the center of the projection at Z = -1, X=0, and Y=0, enter:

T3D, /RESET, ROT = [ 30,0,0], PERS = 1.

Transformations may be cascaded, for example:

T3D, /RESET, TRANS = [-.5,-.5,0], ROT = [0,0,45]

T3D, TRANS = [.5,.5,0]

The first command resets, translates the point (.5,.5,0) to the center of the viewport, then rotates 45 degrees counterclockwise about the Z axis. The second call to T3D moves the origin back to the center of the viewport.