Graphics Programs Reference
In-Depth Information
Let's generalize the preceding passage just a little bit more. Suppose the center of the
circle is at some arbitrary point (xo,yo) as shown in Figure 5.16 and we want to know
the coordinates of a point for any particular angle.
-Y
(0,0)
-X
+X
(xo, yo)
x
angle
y
r
(x, y)
+Y
Figure 5.16 Calculating a point on an offset circle
The equations above need to be modified as follows:
a = angle * Math.PI / 180
x = xo + r * Math.cos(a)
y = yo + r * Math.sin(a)
Figure 5.17 Formulas for calculating a point on any circle
Exercise 5.1: Circular Motion of One Object
Now that we know how to calculate the coordinates of a point on a circle when we are
given its angle, let's see what we can learn from solving the simple problem of having
a single object move along a circular path. Suppose we have a top view of a roulette
“training” wheel. It's not a real wheel but a simplified one so that, like so many of us,
the roulette ball can practice going around in circles. Figure 5.18 illustrates a typical
screen from our exercise.
 
Search WWH ::




Custom Search