22. Translation & Rotation I

187 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
187
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

22. Translation & Rotation I

  1. 1. From last time… • Solar System (with 2 constructors)! • Using sin() on size, color, and position! • Using Perlin noise() in 2 and 3 dimensions! • Let’s talk about recursion…
  2. 2. Recursion • A method which calls itself… myMethod() { doSomething(); } doSomething() { print(“Hey!”); } myMethod() { myMethod(); } myMethod() { myMethod(); } myMethod() { myMethod(); } myMethod() { myMethod(); } An infinite loop. FOREVER.! This is bad.
  3. 3. Recursion • Therefore you must provide an exit condition! • “I’m going to keep calling myself until I reach my exit condition.”! • This is similar to while and for loops! • Demo: Recursive Square
  4. 4. CAP Translation &! Rotation I
  5. 5. The Z Axis + x– x + y – y + z – z
  6. 6. translate() • translate() shifts the origin of our sketch temporarily–for the current draw loop! • Use P3D or OPENGL rendering:! ! size(500, 500, P3D); • Tell it how far you want to move the origin:! translate(moveX, moveY, moveZ);
  7. 7. Demo! Translate
  8. 8. Vertex Shapes • To draw arbitrary shapes, use three methods:! beginShape(); // POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, or QUAD_STRIP vertex(); OR curveVertex(); endShape(); OR endShape(CLOSE);
  9. 9. Demo! Trapezoid
  10. 10. Vertex Shapes In 3D!In 3D! • Basically the same method, but compose a 3D volume out of component shapes in 3D space! • For example, a cube would be 6 squares placed in 3D space
  11. 11. Demo! Top of the Pyramid
  12. 12. ‘Simple’ Rotation • Rotating using the rotation(); method! • Processing rotates around the point of origin! • But the point of origin can move with the translate() method…
  13. 13. Demo! Pyramid Rotation
  14. 14. For next time… • Iteration 2: present on Monday!! • Shiffman, p. 239–252 (Translation/Rotation II)! • Homework 4: moved until after Iteration 2

×