T3D Procedure
Standard Library procedure that accumulates one or more sequences of translation, scaling, rotation, perspective, or oblique transformations and stores the result in the system variable !P.T.
Usage
T3D
Parameters
None.
Keywords
Reset—A scalar which, if nonzero, resets !P.T (the transformation matrix) back to the default identity matrix.
Translate—A three-element vector containing the specified translations in the x, y, and z directions.
Scale—A three-element vector containing the specified scaling factors in the x, y, and z directions.
Rotate—A three-element vector, in units of degrees, containing the specified rotations about the x-, y-, and z-axes. Rotations are performed in the order of X, Y, and then Z.
Perspective—A scalar (p) indicating the z distance to the center of the projection. Objects are projected onto the XY plane at Z=0, and the “eye” is located at point (0, 0, p).
Oblique—A two-element vector containing the 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.
XYexch—If nonzero, exchanges the x- and y-axes.
XZexch—If nonzero, exchanges the x- and z-axes.
YZexch—If nonzero, exchanges the y- and z-axes.
Discussion
All parameters are entered in the form of keywords. The transformation specified by each keyword is performed in the order of its description above. For example, if both Translate and Scale are specified, the translation is done first, even if Scale is the first keyword in the procedure call.
The 4-by-4 transformation matrix, !P.T, is updated by this procedure, but the system variable !P.T3d is not set. This means that for the transformations to take effect, you must set !P.T3d equal to 1, or use the T3d keyword, in any plotting procedure that will make use of this transformation. Since all the graphic routines use the !P.T matrix for output, the T3D procedure can be used to effect graphic output.
 
note
It is possible to create a transformation matrix with T3D that will not work correctly with the SURFACE or SHADE_SURF procedures. The only T3D transformations allowed with these procedures are those that end up with the z-axis placed vertically on the display screen.
This procedure follows the example given in Fundamentals of Interactive Computer Graphics, by Foley and Van Dam, Addison Wesley Publishing Company, Reading, MA, 1982.
 
note
The matrix notation used in the procedure is reversed from the normal PV‑WAVE sense in order to conform to this reference. Moreover, a right-handed system is used, meaning that positive rotations are counterclockwise when looking from a positive axis to the origin.
Example 1
This example demonstrates how to reset transformation, rotate 30 degrees about x-axis, and then do a perspective transformation with center of projection at (0, 0, –1).
T3D, /Reset, Rotate=[30,0,0], Perspective=-1
Example 2
Transformations may also be cascaded. For example:
; Reset, translate center (0.5, 0.5, 0) to the origin, and
; rotate 45 degrees counterclockwise about the z-axis.
T3D, /Reset, Translate=[-0.5, -0.5, 0], Rotate=[0, 0, 45]
; Move the origin back to the center of the viewport.
T3D, Translate=[ 0.5, 0.5, 0]
Example 3
; Create data, and reform it into a 2D array so that
; it can be used with the SURFACE procedure.
b = FINDGEN(37)*10
y = SIN(b*!Dtor)/EXP(b/200)*4
sz = SIZE(y)
j = REFORM(y, sz(1), 1)
; Draw a 3D axis and set up a 3D screen.
SURFACE, j, /Nodata, /Save, YMargin=[0, 0], $
   ZStyle=1, ZRange=[0,1]
; Exchange y- and z-axes so that plots are stacked one
; in front of the other along the usual y-axis.
T3D, /YZexch
TEK_COLOR
; Create a line plot stacked on the 3D axis.
PLOT, b, y, /T3d, ZValue=1.0, YMargin=[0, 0], /Noerase
; Fill under the curve.
POLYFILL, b, y, /T3d, Color=WoColorConvert(6), Z=1.0
PLOT, b, y, /T3d, ZValue=0.5, YMargin=[0, 0], /Noerase
; Create and fill a second curve.
POLYFILL, b, y, /T3d, Color=WoColorConvert(8), Z=0.5
PLOT, b, y, /T3d, ZValue=0.0, YMargin=[0, 0], /Noerase
; Create and fill a third curve.
POLYFILL, b, y, /T3d, Color=WoColorConvert(7), Z=0.0
T3D, /Reset
See Also
System Variables: !P.T, !P.T3d
For more information and examples, see the PV‑WAVE User’s Guide.