• No results found

Euler’s Method and Physically-Based Animation

In document Applications of Calc I Textbook (Page 64-69)

Euler’s Method can be used in a variety of cases for creating physically-based animations. Although the technique is not the most accurate, the 4th Order Runge-Kutta method is a

55 far superior technique, for the purposes of creating simple animations it is suitable. We will look at two different examples where Euler’s Method is needed because the solutions to the ODEs are difficult to find.

Projectile Motion with Air Resistance

Earlier in the chapter, we developed the equations for the motion of a projectile. However, we assumed that there was no air resistance. In reality, air resistance, referred to as air drag, plays an important role in the motion of a projectile. The effects of air drag is approxi- mately proportional to a particle’s velocity. Thus, the differential equations for the x and y components are d2x dt2 =−kvvx(t) (4.41) and d2y dt2 =−g−kvvy(t) (4.42) where v =pvx(t)2+vy(t)2 and k = ρCA 2m (4.43)

where ρ is the density of the air, A is the silhouette area of the particle, m is its mass, and C is the drag coefficient. The fact that acceleration is a function of velocity makes this a difficult problem to solve analytically. However, with Euler’s Method it is fairly easily to approximate the solution. Of course, since we are starting from F = ma, finding the particle’s position as a function of time requires using Euler’s Method twice for each time step, once to find the velocity in the x and y directions, and once to find the position. Figure 4.4 shows the results of an animation for a projectile subject to air resistance. The animation uses a step size of h = 0.1. The figure shows the initial conditions for both position and velocity. Also note thatr= 0.6 is the initial angle and is in radians. The motion path differs from the path in Figure 4.2. One can easily see how air drag affects the projectile’s motion.

Orbital Motion

In the case of one planetary body moving around another, we can begin with the Law of Gravitation

F =GMm

r2 rx(t) (4.44)

Figure 4.4: The results of an animation showing projectile motion subject to air resistance. The trail shows the path of the object.

F =GMm

r2 ry(t) (4.45)

where G is a gravitational constant, M is the mass of one body, m is the mass of another body, r2 is the square of the distance between the two bodies, and r

x(t) and ry(t) are the x

and y components of the direction between the first and second body. From here, we make two assumptions. First, since F =mathe masses cancel each other out. Second, we assume one of the bodies is at the origin. The two differential equations that describe the motion of one body around the another in terms of x and y,

d2x dt2 =− Gx(t) r(t)2 (4.46) and d2y dt2 =− Gy(t) r(t)2 . (4.47) Note thatr(t) =prx(t)2+ry(t)2 = p

x(t)2 +y(t)2. The reason we can make this substitu- tion is from our assumption that one of the bodies is at the origin.

We can, once again, use Euler’s Method twice for each time step, once to find the x and y components of velocity and once to find the position of the body. Figure 4.5 show

57

Figure 4.5: The results of an animation showing orbital motion. The trail shows the path of the object.

the results of an animation for one planetary body orbiting around another. The animation uses a step size ofh= 0.1. One can see how the stationary body’s gravitation and distance to the orbital body effects the motion of the orbital body. The closer the orbital body is to the stationary body, the faster it moves per time step.

Conclusions

In this chapter, we have examined how Calculus, specifically differentiation and the an- tiderivative can be used to find the motion equations need to create physically based ani- mations of particles and objects. We also examined how to approximate motion equations when finding the analytic solution to a differential equation is too difficult. The examples described in this chapter also show how important Calculus is in understanding Physics. The approaches taken to approximate solutions to ODEs using Euler’s Method will work for more complicated situations as well. For example, in video games, there can be many objects moving and interacting with many other objects. It is important to remember that we can always approximate the position of an object by starting withF =maand using the basic Euler Method technique. The key is to understand that F is the sum of all the forces acting on the particle. Although we did not discuss it in this chapter, collision detection and response is another critical part of creating physics engines and physically based anima- tions. The premise is to determine if and when an object will collide with another, and how that collision effects the objects in question. However, as we have seen, one can still make

Chapter 5

Optimization to Engineering

In document Applications of Calc I Textbook (Page 64-69)

Related documents