Pick a model


Define the model

Keep the names short; we will type them a lot.


Define the model

Keep the names short; we will type them a lot.

(define-struct pv (pos vel))

Example needed

Create a pv structure called ex1.


Sketch

(make-pv (make-posn 50 200)
		 (make-posn 10 -30))

update-pos


scale-velocity


turn-180

What would this mean? Sketch first.


Bouncing off walls 1

Should you bounce off of a wall?

Sketch three true and three false.

should-bounce-r? : pv num(xwall) -> boolean

The wall on the right is at x=xwall.


Bouncing off walls 2

should-bounce-r? : pv num(xwall) -> boolean

The wall on the right is at x=xwall.

Now actually write the function.


Bouncing off walls 3

bounce-r-velocity: pv -> posn(new-velocity)

Given that you bounced, what should your new velocity be?

Draw a sketch!