Animation Lecture 17 Wed Oct 3 2007 Animation
- Slides: 34
Animation Lecture 17 Wed, Oct 3, 2007
Animation may include n n n Moving the objects in the scene. Changing the shapes of objects. Moving the camera through the scene.
Moving Objects Typically objects move with constant velocity or constant acceleration. If velocity is constant, then n position(t) = vt + s 0. If acceleration is constant, then n n velocity(t) = at + v 0, position(t) = ½ at 2 + v 0 t + s 0.
Constant Velocity Assume n n The velocity is constant, The motion is in the x direction only. Then x(t) = vt + s 0. During a time interval t, n n v is constant (so v = 0), and The position changes by x = v t.
Constant Velocity The clock will give us the time interval t. Get the initial time t 0 by last = clock(). Get the time interval as t = clock() – last. Update last.
Updating the Position void idle() { int now = clock(); float time = (float)(now – last)/CLOCKS_PER_SEC; pos. x += v*time; last = now; return; }
Constant Acceleration When an object is accelerating, its position and speed are changing. If the acceleration is constant, then n n The speed changes linearly. The position changes quadratically.
Constant Acceleration In this case, we may use position(t) = ½ at 2 + v 0 t + s 0 to compute the present position, or We may store the current position and current velocity and update both of them. We will use the second option.
Updating Position and Velocity A simple calculation is n n v = a t, x = v t.
Updating Position and Velocity However, if a > 0, then n n v = a t, v = v + v x = v t. x = x + x will overestimate x , while…
Updating Position and Velocity n n x = v t. x = x + x v = a t, v = v + v will underestimate x. Why? Does it matter?
Updating Position and Velocity It turns out that if a is constant, then we can use the average velocity vavg over the time interval t and get the correct value for x. That is, n n n v = a t vavg = (v + v))/2 = v + ½ v x = vavg t.
Updating Position and Velocity void idle() { int now = clock(); float time = (float)(now – last)/CLOCKS_PER_SEC; v_new = v + a*time; pos. x += 0. 5*(v + v_new)*time; v = v_new; last = now; return; }
Circular Motion By incrementing the angle in the idle() function, we may use gl. Rotate() to rotate an object or to move it in a circle.
Changing the Shape of Objects can be compressed or stretched by calling Scalef() with variable scale factors. Increment the scale factors in idle(), using the clock() function.
A Rolling Ball In the next demo, a red ball appears to roll along a strip. Is the ball really rolling?
A Rolling Ball Read Run
A “Rolling” Beachball Make the plain red ball a beachball. Now we can tell whether the ball is rolling.
A “Rolling” Beachball Read Run
Let’s Get This Ball Rolling! Now we will add a rotation to make the ball roll. The rate of rotation must be coordinated with the distance the ball moves, or else the ball will appear to be slipping or spinning.
An Accelerating Beachball Read Run
An Accelerating Beachball Suppose that the ball moves a distance x. Then it has rolled a distance x along its circumference. If r is the radius, then the angle is x/r, in radians. Perform the rotation: gl. Rotatef((180. 0/PI)*dx/rad, 0. 0, 1. 0);
Rolling Beachball in 2 D In the final rolling-ball example, the ball is rolling around in a 2 D plane. It is easy to calculate the ball’s position. However, it’s orientation depends on the particular path it followed to get there. That is, we must know the previous orientation to compute the new orientation.
Rolling Beachball in 2 D Read Run
Stretching the Beachball Read Run
The Bouncing Ball The bouncing ball in the following example animates the shape of the object, as well as its position.
Bouncing Ball
Bouncing Ball The ball bounces in a semicircular arc.
Simulation of Motion in General Let the position of an object be given by P(t) = (x(t), y(t), z(t)). Then the change in position is given by P (t) = (x (t), y (t), z (t)). We may approximate this by P(t) = (x (t) t, y (t) t, z (t) t) P(t) += P(t).
A More Realistic Bounce We want the ball’s trajectory to be a parabola with height h and let s be the time required to travel this trajectory. For simplicity, assume that y(0) = 0. Then y(s/2) = h, y (s/2) = 0, and y(s) = 0. What is the formula for y(t)?
A More Realistic Bounce The equation of a parabola is quadratic. Therefore, y(t) = at 2 + bt + c for some numbers a, b, c. To find a, b, and c, we solve the equations n n y(0) = c = 0 y(s/2) = as 2/4 + bs/2 + c = h y(s) = as 2 + bs + c = 0 y (s/2) = as + b = 0.
A More Realistic Bounce The solution is a = -4 h/s 2, b = 4 h/s, c = 0. So, y(t) = -4 h(t/s)2 + 4 h(t/s). Then y (t) = -8 ht/s 2 + 4 h/s = (4 h/s)(1 – 2 t/s).
A More Realistic Bounce We program this as time += delta. T; ball. Pos. x += (b. Dist/b. Rate)*delta. T; ball. Pos. y += (4. 0*b. Hgt/b. Rate)*(1. 0 – 2. 0*time/b. Rate)*delta. T;
A More Realistic Bounce
- 01:640:244 lecture notes - lecture 15: plat, idah, farad
- Traditional vs computer animation
- What is organic chemistry
- System czwórkowy
- Oct vizsgálat
- Meth eth prop but mnemonic
- Sunset on oct 31
- Hidrocarbonetos ramificados
- Jhlt. 2019 oct; 38(10): 1015-1066
- Eteno
- Oct 3 1993
- Alkane alkene alkyne
- Meth eth prop but pent hex
- Met et prop but pent hex hept oct non dec
- Premium sanitas
- Jhlt. 2019 oct; 38(10): 1015-1066
- Met et prop but pent hex hept oct non dec
- Pent oct hept hex
- Stil oct
- Low na
- Prop but pent hex hept oct
- Jhlt. 2019 oct; 38(10): 1015-1066
- Characteristics of homologous series
- Visante oct
- Scleral lens oct
- Propil
- Story of mahatma gandhi
- Meth eth prop
- Prop but pent hex hept oct
- Prop but pent hex hept oct
- Propylhexane formule semi-développée
- Jhlt. 2019 oct; 38(10): 1015-1066
- Cuny first qc
- Is 800:2007
- 19 februari 2007 hari apa