Thursday, November 8, 2007

Practice for test for next week (Thursday)

Here are some questions that you may want to practice. The only HW this weekend is to complete the assignment and practice for the test.

The best way to learn is to try to do it on your own. When needed look at the solution (first comment) and then try again. Write notes. Once you get it do not stop there. Come back to it later and do it again until you start feeling really good inside. It will be such an enjoyable experience at the end. :)

1. Can you explain in your own words the meaning of the commands and why do we need themm:
A. local t x y etc.
B. t=t+1/10000
C. loop
D. x=100*t jt x x
E. r=circle 100*t


2. Make a small program w/o looking ta any notes that moves a small circle from:

A. (0,0) to (100,0)
B. (20,100) to (80,100) How would you slow it down by a factor of 3?
C. (100,100) to (0,0)
D. (15,60) to (-120, 110) How would you make sure the answer is correct?
I suggest to practice with D a lot by picking up your own points and testing yourself.

3. Make a small program that moves a small object chaning colors randomly around a circle of radius 120 5 times around the center of the screen
////////////////////////////////////
If master this up to here you are a B student on this material. If you want go further.

4. Modify the previous program so that it creates a spiral rather than a circle and turns around the center 3 times

5. Make a program that moves two points at the same time from (100,100) and (-100,-100) and meet at the origin and then make the spiral of life explode

6. Make a program that moves a point from (0,0) to (100,0) and then from (100,0) to (100,100)

7. Move an object along a line segment hence and forth 5 times <------------>

8. Play with colors that change smoothly and not randomly

1 comment:

Dani said...

Some answers


1.
A. local t x y etc. defines variables like boxes inside the computer. draw a picture...
B. t=t+1/10000 increments the value of t by a very small amount
C. loop example t=0 loop 10000 [ t=t+1] whatever is in the square brackets is repeated the number of times specified
D. x=100*t jt x 0 circle 3 defines the value of x puts a small circle in the coordinate x 0
E. r=100*t circle r make a circle of diameter 100*t

2. Make a small program w/o looking take any notes that moves a small circle from:

A. (0,0) to (100,0)
B. (0,100) to (80,100)
C. (100,100) to (0,0)
D. (-20,60) to (-120, 110)


B. local t x
t=0
loop 10000 [t=t+0.0001 x=20+ 60*t
jt x 100 circle 3]
//to slow it down by a factor of 3 we will change 10000--->30000 and 0.0001 to 0.0001/3

D. First find the m and the b in the equation y=m*x+b
m=-0.5 b=50 so y=-0.5*x + 50
next define the function x so that x(0)=-20 and x(1)=-120. The answer is x=-20 -100*t
the final answer is:
local t x y
t=0
loop 10000 [t=t+0.0001
x=-20 - 100*t y=-0.5*x+50 //make sure there is a space after the "-"
jt x y
circle 3]

To make sure the answer is correct you would type something like the following at the end:
jt -20 60 circle 10 jt -120 110 circle 10

3. local t x y
t=0
loop 100000 [t=t+0.00001
x=100*Cos(360*t*5)
y=100*Sin(360*t*5)
jt x y
color rnd 512 [circle 50]
]

Contributors