20. mathematics i
TRANSCRIPT
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
CAP 3032
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
random() Numbers
• random(high); OR random(low,high);!
• Weighted randomness: we’ve seen this many times before!
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
Demo!Fireflies
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();
Demo!Drawing on Arcs
For next time…
• Iteration 2: we present in 1 week!!
• Reading: Shiffman, p. 214–225 (Mathematics II)