go to previous page   go to home page   go to next page

Answer:

actual x valuex' = x * 599/(2*PI)
0.0 0
2*PI 599

The answers are easy to figure out since multiplication by zero results in zero (at one end) and the (2*PI) in the numerator cancels the (2*PI) in the denominator (at the other end.)


Linear Equation

X Y grid

Since the equation is linear, all the points in between will also be correct. Here is the same thing for the integer Y that is needed to graph the function. Recall that the range of sin(x) (-1 to +1) is to be represented in an applet with a height of 400 pixels. So we need to map (-1 to +1) to (0 to 399).

actual y valueinteger y' to fit applet height
-1.0 399
+1.0 0

Remember that Y=0 for applets corresponds to the top row and that Y=399 will be the bottom row. Do this by using another linear equation:

y' =  -y * 399/2 + 399/2

But, there is a problem. The user might resize the window so that the width and height are not the 600 and 400 we have been planning on.


QUESTION 11:

What methods of JPanel get the current width and height of the panel?