20. Mathematics I

184 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
184
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

20. Mathematics I

  1. 1. From last time… • Added a PONG countdown and sound effects! • Minim: AudioPlayer vs. AudioSample! • Briefly discussed external libraries & debugging! • Homework 3 was graded and returned
  2. 2. CAP Mathematics I
  3. 3. % Modulo Operator • Use modulo to make “counter” variables! • Similar to division but returns the remainder! • The remainder never be greater than the divisor 0 % 3 0 R0 0 1 % 3 0 R1 1 2 % 3 0 R2 2 3 % 3 1 R0 0 4 % 3 1 R1 1
  4. 4. random() Numbers • random(high); OR random(low,high);! • Weighted randomness: we’ve seen this many times before!
  5. 5. Perlin noise() • noise(x); • noise(x,y); • noise(x,y,z); • We have to feed it a “time” value! • Always returns a float between 0 and 1
  6. 6. Demo! Fireflies
  7. 7. Radians & Degrees • Radians = 2 π ( Degrees / 360 )! • float myRadians = radians(360); // 6.2831… • float myDegrees = degrees(TWO_PI); // 360.0 • QUARTER_PI HALF_PI PI TWO_PI TAU • sin(); cos(); tan();
  8. 8. Demo! Drawing on Arcs
  9. 9. For next time… • Iteration 2: we present in 1 week!! • Reading: Shiffman, p. 214–225 (Mathematics II)

×