Graphics Programs Reference
In-Depth Information
26
27
28
29
30
31
32
// move the car along the path
angle -= 5; // update the angle
a = angle*Math.PI/180;
object_mc._x = xc + xr * Math.cos(a);
object_mc._y = yc + yr * Math.sin(a);
object_mc._rotation = angle - 90;
}
Tip: Use either the Left Arrow key or the Up Arrow key to completely flip the path
around. Although the path will appear to look the same, a negative scale factor will be
generated. Negative scale factors can be very useful in flipping objects horizontally or
vertically. In our case, the negative scale factor that is generated will give the car a
very complex motion. It spins on its own axis in a counterclockwise movement while
traveling around the path in a clockwise direction.
Sine and Cosine Waves
Now that we can have objects moving along circular and elliptical paths using the sine
and cosine functions, let's take a look at the graphs of these functions. Both functions
are examples of periodic functions, or functions that repeat themselves. To help you
Figure 5.25 Plotting the sine and cosine functions
Search WWH ::




Custom Search