home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / p / ply15dat.zip / ROBARM.PI < prev    next >
Text File  |  1992-10-23  |  4KB  |  142 lines

  1. //
  2. // Animation of a robot arm solving the "Towers of Hanoi" problem.
  3. // Author: Alexander Enzmann
  4. //
  5. viewpoint {
  6.    from <-4,14,-30>
  7.    at <4,2,0>
  8.    up <0,1,0>
  9.    angle 13
  10.    resolution 320, 160
  11.    aspect 2
  12.    }
  13.  
  14. //viewpoint {
  15. //   from <4, 8, -30>
  16. //   at <8,2,0>
  17. //   up <0,1,0>
  18. //   angle 15
  19. //   resolution 320, 160
  20. //   aspect 2
  21. //   }
  22.  
  23. background midnight_blue
  24. light <10, 20, -20>
  25.  
  26. include "colors.inc"
  27. include "robtex.inc"
  28.  
  29. // How many steps will be taken between moves?  They are divided
  30. // between three sub-steps: up, over, down.  Each of these will
  31. // be assumed to take 10 frames, with 30 frames for the move.
  32. define frames_per_submove 6
  33. define submoves_per_move 6
  34. define frames_per_move submoves_per_move * frames_per_submove
  35. define total_moves 7
  36.  
  37. // Define the number of frames in the animation
  38. start_frame 0
  39. end_frame total_moves * frames_per_submove * submoves_per_move - 1
  40.  
  41. define move floor(frame / frames_per_move)
  42. define submove floor(fmod(frame, frames_per_move) / frames_per_submove)
  43. define submove_increment fmod(frame, frames_per_submove) / (frames_per_submove - 1)
  44.  
  45. // Build the pegs
  46. include "pegs.inc"
  47. pegs { translate <peg_distance, 0, 0> }
  48.  
  49. // Build and position the wafers
  50. include "robwafer.inc"
  51. wafer0 { translate <peg_distance, wafer_height0, wafer_offset0> }
  52. wafer1 { translate <peg_distance, wafer_height1, wafer_offset1> }
  53. wafer2 { translate <peg_distance, wafer_height2, wafer_offset2> }
  54.  
  55. // Build and align the robot arm
  56. define robot_arm_alpha -atan(moving_wafer_offset / peg_distance)
  57. define robot_arm_theta -asin(0.5 * (wafer_width - 0.1))
  58.  
  59. define hand_length 0.3 + 1.5 + 2 * cos(robot_arm_theta)
  60. define distancexy sqrt(peg_distance * peg_distance +
  61.                        moving_wafer_offset * moving_wafer_offset) -
  62.                   hand_length
  63. define distancez (moving_wafer_height + 0.4) - 3
  64. define wafer_distance sqrt(distancez * distancez + distancexy * distancexy)
  65.  
  66. define robot_arm_beta -asin(distancez / distancexy)
  67. define section2_offset wafer_distance - 4
  68.  
  69. include "robarm.inc"
  70. robot_arm
  71.  
  72. // Add a floor underneath the arm & the pegs
  73. object {
  74.    disc <4, -0.0001, 0>, <0, 1, 0>, 10
  75.    texture { checker matte_brown, matte_orange }
  76.    }
  77. // Here's how we play:
  78. //
  79. // Stage 1:
  80. //
  81. //      |          |          |
  82. //     ***         |          |
  83. //    *****        |          |
  84. //   *******       |          |
  85. //  ---------  ---------  ---------
  86. //
  87. // Stage 2:
  88. //
  89. //      |          |          |
  90. //      |          |          |
  91. //    *****        |          |
  92. //   *******      ***         |
  93. //  ---------  ---------  ---------
  94. //
  95. // Stage 3:
  96. //
  97. //      |          |          |
  98. //      |          |          |
  99. //      |          |          |
  100. //   *******      ***       *****
  101. //  ---------  ---------  ---------
  102. //
  103. // Stage 4:
  104. //
  105. //      |          |          |
  106. //      |          |          |
  107. //      |          |         ***
  108. //   *******       |        *****
  109. //  ---------  ---------  ---------
  110. //
  111. // Stage 5:
  112. //
  113. //      |          |          |
  114. //      |          |          |
  115. //      |          |         ***
  116. //      |       *******     *****
  117. //  ---------  ---------  ---------
  118. //
  119. // Stage 6:
  120. //
  121. //      |          |          |
  122. //      |          |          |
  123. //      |          |          |
  124. //     ***      *******     *****
  125. //  ---------  ---------  ---------
  126. //
  127. // Stage 7:
  128. //
  129. //      |          |          |
  130. //      |          |          |
  131. //      |        *****        |
  132. //     ***      *******       |
  133. //  ---------  ---------  ---------
  134. //
  135. // Stage 8:
  136. //
  137. //      |          |          |
  138. //      |         ***         |
  139. //      |        *****        |
  140. //      |       *******       |
  141. //  ---------  ---------  ---------
  142.