Graphics Programs Reference
In-Depth Information
Degrees to radians: angleInRadians = angleInDegrees * ( Math.PI/180 )
Radians to degrees: angleInDegrees = angleInRadians * ( 180/Math.PI )
Figure 5.7 Converting degrees and radians
If you want to get a feel for the numerical difference between degrees and radians,
open angleCalculator.swf in the Chapter 5 folder. You can turn the steering wheel
and the car clockwise and counterclockwise by using the Left Arrow and Right Arrow
keys. The angle of the car and steering wheel is provided in both degrees and radians.
Note that Flash allows you to go more than 360 degrees both positively or negatively
without error. Also note that when specifying angles, a value of -30 degrees will yield
the same results as 330 degrees and so forth.
Figure 5.8 Angles in degrees and radians
Let's take a quick look at the script for the calculator. Open angleCalculator.fla in
the Chapter 5 folder. Click on the actions layer to display the script shown in Figure
5.9. The variable angleInDegrees will control the turning of both the steering wheel
and the car. We begin by initially setting this angle to 0 degrees in line 2 since no
rotation has yet occurred.
Search WWH ::




Custom Search