20. mathematics i

9

Click here to load reader

Upload: joseph-murphy

Post on 03-Jul-2015

49 views

Category:

Education


3 download

TRANSCRIPT

Page 1: 20. Mathematics I

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

Page 2: 20. Mathematics I

CAP 3032

Mathematics I

Page 3: 20. Mathematics I

% 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 01 % 3 0 R1 12 % 3 0 R2 23 % 3 1 R0 04 % 3 1 R1 1

Page 4: 20. Mathematics I

random() Numbers

• random(high); OR random(low,high);!

• Weighted randomness: we’ve seen this many times before!

Page 5: 20. Mathematics I

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

Page 6: 20. Mathematics I

Demo!Fireflies

Page 7: 20. Mathematics I

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();

Page 8: 20. Mathematics I

Demo!Drawing on Arcs

Page 9: 20. Mathematics I

For next time…

• Iteration 2: we present in 1 week!!

• Reading: Shiffman, p. 214–225 (Mathematics II)