home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Education / xModels 2D and 3D / Tutorial Examples / Tutorial 8. 3D Transformations < prev    next >
Encoding:
Text File  |  1995-06-22  |  2.4 KB  |  58 lines  |  [TEXT/X_#a]

  1. ; Tutorial 8: 3D Transformations
  2.  
  3.       animate 60
  4.  
  5. ; Transformations in 3D are only a little more complicated
  6. ; than 2D transformations.  (Visualizing their use is
  7. ; a lot more difficult for most people, though.)  First of
  8. ; all, there is nothing in xModels-3D corresponding to "xskew",
  9. ; "yskew", or "rotate ... about ...".  Scaling, rotation, and
  10. ; translation all have their place, however.
  11. ;
  12. ; Scaling can take three parameters, giving scale factors in
  13. ; the x, y, and z directions respectively.  For example,
  14. ; "cube scale 2,4,6" makes a 2-by-4-by-6 "brick".  As you
  15. ; might expect, "scale 3" is short for "scale 3,3,3", and,
  16. ; not so obviously, "scale 3,7" is short for "scale 3,7,7".
  17. ; There are also separate "xscale", "yscale", and "zscale"
  18. ; commands.
  19. ;
  20. ; The "translate" transformation takes three parameters
  21. ; which give displacements in the x, y, and z directions
  22. ; repsectively.  You can also use "xtranslate", "ytranslate",
  23. ; and "ztranslate" with one parameter.  Note that
  24. ; "ztranslate -5" moves an object away from you while
  25. ; "ztranslate 5" moves an object towards you.
  26. ;
  27. ; There are three different rotation transformations:
  28. ;
  29. ; 1) "xrotate" specifies a rotation about the x-axis:
  30.  
  31.           square scale 4
  32.               ztranslate 7  ; Move the square towards you
  33.               xrotate 0:360 ; Square rotates around the x-axis,
  34.                             ; moving up and away from you then
  35.                             ; down and back.  The center of the
  36.                             ; square moves along a circle in
  37.                             ; the yz-plane
  38.  
  39. ; 2) "yrotate" specifies a rotation about the y-axis
  40.  
  41.           circle scale 4
  42.               ztranslate 7  ; Move the circle towards you
  43.               yrotate 0:360 ; Circle rotates around the y-axis,
  44.                             ; moving right and away from you then
  45.                             ; left and back.  The center of the
  46.                             ; circle moves along a circle in
  47.                             ; the xz-plane.
  48.  
  49. ; 3) "zrotate" specifies a rotation about the z-axis.  This is
  50. ;    similar to rotation in 2D about the origin, and in fact
  51. ;    you can use "rotate" as a synonym for "zrotate"
  52. ;    See the previous tutorial for an example.
  53. ;
  54. ; It is not necessarily easy to use these rotations to position
  55. ; an object in just the right position and orientation.   It
  56. ; will probably require some practice and some analysis of
  57. ; examples.
  58.