[racket] Bothersome solution to HtDP/2e Rocket Landing Discussion

27 views
Skip to first unread message

Lawrence J Winkler

unread,
Feb 23, 2014, 4:14:34 PM2/23/14
to us...@racket-lang.org

I recently starting reading HtDP/2e to evaluate the approach to teaching programming. My motivation, in part, stems from the recent Computer Science Education Week last December, where many were given the opportunity to experience one hour of programming. 

I'm interested in reviewing different teaching approaches and processes and I soon came upon your rocket landing demo in the Prologue and felt uncomfortable with the discussion and solution create-rocket-scene.v3. (I haven't read much further than this in any detail, so you may already address this issue later). 

In particular, the solution adjusts the position of the rocket relative to the HEIGHT of the empty-scene and the image-height, whereas I'm much more comfortable with a solution conceptualized differently and independent of size of the  scene.

Where in the function (create-rocket-scene height), height is the position of the center of the image, my solution is that height would be the height of the bottom of the image. Thus, something like the following makes more sense to me. (using BSL) 

(define (place-image-bottom img x y canvas)  
 (place-image img x (img-center-pos img y) canvas))

(define (img-center-pos img vert-pos) (- vert-pos (/ (image-height img) 2)))

(define (create-rocket-scene.v3 ht)
 (if (<= ht 100) (place-image-bottom rocket 50 ht (empty-scene 100 100))
     (place-image-bottom rocket 50 100 (empty-scene 100 100))))

In any case, it would seem easier for me to motivate this abstraction to new students. 

Thanks
-------------------------------
Larry Winkler
5306 Loruth Ter
Madison Wisconsin 53711
Mobile: 608-345-0627
--------------------------------


Mark Engelberg

unread,
Feb 23, 2014, 4:33:25 PM2/23/14
to Lawrence J Winkler, us...@racket-lang.org
Take a look at the function put-pinhole, which will allows you to create a version of the rocket image with the "pinhole" at the bottom center of the rocket.  If you do that, I think you'll be able to easily create place-image logic for the rocket example that is more to your liking.



____________________
  Racket Users list:
  http://lists.racket-lang.org/users


Matthias Felleisen

unread,
Feb 23, 2014, 4:43:58 PM2/23/14
to Lawrence J Winkler, us...@racket-lang.org
On Feb 23, 2014, at 4:14 PM, Lawrence J Winkler wrote:

I recently starting reading HtDP/2e to evaluate the approach to teaching programming. My motivation, in part, stems from the recent Computer Science Education Week last December, where many were given the opportunity to experience one hour of programming. 

I'm interested in reviewing different teaching approaches and processes


To evaluate HtDP/2e you should not read the Prologue at all. Or skip to the sections called "You are a Programmer Now" and "Not!". The point of the Prologue is to give readers an idea of 'garage programming' (term coined by famous software engineering researcher, Fred Brooke) and to then say 'but how do people go about designing programs as opposed to puzzling them out.' 





(define (place-image-bottom img x y canvas)  
 (place-image img x (img-center-pos img y) canvas))

(define (img-center-pos img vert-pos) (- vert-pos (/ (image-height img) 2)))

(define (create-rocket-scene.v3 ht)
 (if (<= ht 100) (place-image-bottom rocket 50 ht (empty-scene 100 100))
     (place-image-bottom rocket 50 100 (empty-scene 100 100))))

In any case, it would seem easier for me to motivate this abstraction to new students. 


Here is the experiment that Mark proposed: 

(require 2htdp/image)

(define ball (circle 30 'solid 'red))
(define table (rectangle 200 10 'solid 'blue))

(define ball-on-table (overlay ball table))

ball-on-table 

(define ball-pb (put-pinhole (/ (image-width ball) 2) (image-height ball) ball))
(define ball-pb-on-table (overlay/pinhole ball-pb table))

ball-pb-on-table

Reply all
Reply to author
Forward
0 new messages