Study Guides (247,988)
IAT 265 (12)
Final

# IAT265 Periodic Motion Animation Example.docx

2 Pages
149 Views

School
Department
Interactive Arts & Tech
Course
IAT 265
Professor
Matt Lockyer
Semester
Winter

Description
Periodic Motion Animation float xPos, yPos, dx, dy, dTheta, amplitude, rotation, objectSize; void setup() { size(500, 500); smooth(); objectSize = 20; // inialize the object size; in this case, the diameter xPos = objectSize/2; // move the object on screen to start yPos = height/2; dx = 1; // x velocity, or the small amount added to xPos each frame dTheta = PI/200; // angular velocity, or the small amount added to rotation each frame amplitude = 100; } void draw() { background(255); // clear the background by setting it to white each frame drawObject(xPos, yPos, atan(cos(rotation)), objectSize); // draw the object on screen // UPDATE positions for next frame // increment the xPos by the amount dx xPos += dx; // set the yPos to the sin of the rotation yPos = amplitude * sin(rotation) + height/2; /*** Notice this difference. This time we are setting yPos EQUAL to equation. We are not adding dy to it. We, instead, are incrementing dTheta. sin(0) = 0 cos(0) = 1 Use cosine if you want the object to start at the top of the wave. Use sine if you want the wave to start in the middle. If you use cosine, you'll need to use atan(-sin(r
More Less

Related notes for IAT 265
Me

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.