Graphics Programs Reference
In-Depth Information
Step 2: Create a spiral rotation
Enough fooling around. Let's get down to it and create a spiral. Modify the y contribu-
tion to the path by dividing the cosine of the angle by 2 as shown below. When you test
the movie, you should get a rather sweeping spiral motion. This is what's happening: as
we noted in Chapter 5, the cosine is a periodic function that repeats itself. When we use
a/2 inside the cosine function for y, then it takes twice as long to repeat itself as it does
for the x-value. This value is called the frequency, and we can say that the frequency of
the y - component is half that of the x - component.
36
37
38
39
40
// put it on the circle
thisObj.x = xc + r * Math.cos(a);
thisObj.y = yc + r * Math.cos(a/2);
thisObj.z = zc + r * Math.sin(a);
Step 3: Reduce the z radius value
Our spiral has a nice sense of depth to it, but it runs off of the screen. We can adjust
for this in a number of ways, one of which is to reduce the movement in the z - direction.
The perspective will be a little less dramatic but will still work quite well. Let's reduce
the radius in the z - direction by cutting it in half as shown below. Note that the division
here is outside of the sine function.
36
37
38
39
40
// put it on the circle
thisObj.x = xc + r * Math.cos(a);
thisObj.y = yc + r * Math.cos(a/2);
thisObj.z = zc + r * Math.sin(a)/2;
Step 4: Tighten up the spiral
By decreasing the frequency in the y - direction, we can tighten the spiral and increase
the number of revolutions before the path returns to its initial position. Make the
change below, then save your movie as 6_7_xzSpiralRotation_DONE.fla and test it.
36
37
38
39
40
// put it on the circle
thisObj.x = xc + r * Math.cos(a);
thisObj.y = yc + r * Math.cos(a/4);
thisObj.z = zc + r * Math.sin(a)/2;
 
Search WWH ::




Custom Search