Previous: text Up: ../slides.html Next: unitsinches-centimeters-cm


TRANSFORMATION |

               <LIST | NOLIST>
               <IMAGE | WORLD>
               <ROTATE (X-axis|Y-axis|Z-axis) degrees> |
               <SCALE sx sy sz> |
               <SHEAR (sxy syx) | (sxy sxz syx syz szx szy)> |
               <TRANSLATE tx ty tz>

 In some applications,  such as plotting  of digitized data,  it may  be
 desirable to transform the input coordinates implicitly before they are
 sent  to  a  plot  routine.   This  command  provides  a  powerful  and
 convenient way of defining a general 3-D transformation on the  (x,y,z)
 coordinates.  The order of the  subcommands from left to right  defines
 the order in which the various transformations are to be applied.

 The transformation matrix constructed may be either a world  coordinate
 modelling matrix, or an image transformation matrix, as selected by the
 WORLD and  IMAGE subcommands.   Since use  of an  image  transformation
 matrix is  extremely rare  (it is  applied in  device coordinate  space
 after all other transformations have been done), the default if neither
 keyword is specified is  a world modelling  matrix.  If desired,  these
 matrices may be specified directly with the

 VIEW IMAGE-TRANSFORMATION-MATRIX and  VIEW WORLD-MODELLING-MATRIX

 commands described elsewhere.

 The transformation matrix  so constructed  post-multiplies the  current
 world coordinate modelling matrix or image transformation matrix (which
 are initially unit matrices) in the  CORE system and then replaces  it.
 The post-multiplication allows the various subcommands to be issued  in
 one TRANSFORMATION command,  or on  several consecutive  TRANSFORMATION
 commands, with  the  same  overall effect.

 The modelling matrix is included internally in the total transformation
 matrix mapping world coordinates to normalized device coordinates,  the
 use  of  this   option  entails   no  overhead   whatever.   An   image
 transformation matrix  is  applied at  the  device level,  and  in  the
 current <PLOT79>  implementation,  does introduce  additional  run-time
 overhead on most devices.

 If the command parse fails because of errors, the old matrix remains in
 effect.  Otherwise, the matrix is replaced by the newly computed one.

 If the LIST option is specified, and the top-level LIST OFF command has
 not  been  issued,  the  old  and  new  matrices  are  printed.   Thus,
 specification of  each  subcommand on  separate  "TRANSFORMATION  LIST"
 commands will display the  matrix at each step,  which is often  useful
 for debugging purposes.

 The subcommand  NONE causes  the current  transformation matrix  to  be
 reset  to   a   unit   matrix,  effectively   cancelling   a   previous
 TRANSFORMATION command.

 The subcommand POP causes the previous transformation to be popped from
 the transformation stack, replacing the current one which is discarded.
 The subcommand  PUSH saves  the current  transformation matrix  on  the
 stack, and leaves it as the  current matrix.  Together, they provide  a
 way to  make a  temporary modification  of the  current  transformation
 matrix without knowing what it is,  then to restore the original.   For
 example, a "TRANSFORMATION PUSH ROTATE Z-axis 45" command could precede
 a sequence of plotting commands to draw an object.  The object would be
 rotated 45 degrees about the Z-axis.  Following this, a  TRANSFORMATION
 POP command would revert  to the situation  before the PUSH  subcommand
 was issued.

 The stack depth is of course fixed,  but the limit of 10 levels set  at
 compile time should  be ample.   An error message  is issued  if a  POP
 subcommand is encountered  with an empty  stack, or if  a PUSH  command
 would  cause  a   stack  overflow.    In  either   case,  the   current
 transformation matrix remains unchanged.

 The ROTATE subcommand specifies a  rotation angle in degrees about  the
 axis specified  by  the  following  keyword.   The  angle  is  positive
 counterclockwise looking down  the positive  axis to  the origin.   For
 example, for a Z-axis rotation, the rotated coordinates are given by

 xnew = x*cos(angle) - y*sin(angle)
 ynew = x*sin(angle) + y*cos(angle)
 znew = z

 The SCALE  subcommand may  be  followed by  independent  multiplicative
 scale factors for  the x, y,  and z coordinates.   If fewer than  three
 values are given,  the omitted ones  default to the  same value as  the
 last one.  The new coordinates are given by

 xnew = x*sx
 ynew = y*sy
 znew = z*sz

 The SHEAR  subcommand specifies  either  two shear  factors for  a  2-D
 shear, or six shear factors for a 3-D shear.  For example, 'sxy' is the
 change in x for a unit change in y, and 'syx' is the change in y for  a
 unit change in x.  That is, the new coordinates are

 xnew = x     + y*sxy
 ynew = x*syx + y
 znew = z

 with a 2-D shear, or

 xnew = x     + y*sxy + z*sxz
 ynew = x*syx + y     + z*syz
 znew = x*szx + y*szy + z

 with a  3-D shear.   They may  be used  to obtain  a skewed  coordinate
 system.

 The TRANSLATE subcommand is  used to move the  origin (0,0,0) to a  new
 point (tx,ty,tz).  The new coordinates are given by

 xnew = x - tx
 ynew = y - ty
 znew = z - tz

 For example, suppose we  have an object defined  in coordinates in  the
 range 0..100, and we wish to rotate it by 180 degrees about the  Z-axis
 passing through the point (50,50,0) before plotting it.  The command to
 effect this is

 TRANSFORM TRANSLATE 50 50 ROTATE Z-axis 180 TRANSLATE -50 -50

 As a second example, suppose  we want to plot  the mirror image of  the
 same object, where the reflection is about the yz plane passing through
 the center point (50,50,0).  The necessary command is

 TRANSFORM TRANSLATE 50 50 SCALE -1 1 TRANSLATE -50 -50