[plt-dev] Re: [plt-scheme] scaling and rotating images using image.ss

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sat Nov 14 08:25:52 EST 2009

I think what you did at the end is the way that I'd do it.

This suggests that the library needs to support invisible ellipses
(equality is going to be a pain with those in there, tho, but I guess
it is nothing new when you consider that there are already zero-width
and zero-height rectangles).


On Sat, Nov 14, 2009 at 12:18 AM, John Clements
<clements at brinckerhoff.org> wrote:
> On Sep 26, 2009, at 6:29 AM, Matthias Felleisen wrote:
>> 1. htdp/world is deprecated, use 2htdp/universe instead.
>> 2. we consider the pinhole approach to our image library as a mistake. To
>> solve the problem Robby is working on 2htdp/image, a replacement for the
>> image library. When it comes out (end of semester probably) it will support
>> rotate and other such operations, plus comparisons will be much faster.
> I'm surprised to say it, but right now I'm *really missing the pinhole*.
> I'm trying to write a function in 2htdp/image that draws, say, 36 copies of
> a shape arranged in a big "circle" around a center.  With pinholes, this was
> easy.  Move the pinhole way off to the left, then rotate the thing around
> the pinhole by 10 degrees, 20 degrees, etc. Overlay them all, and you're
> done. [*]
> With the new approach, I'm finding this nearly impossible.  The natural
> approach involves, for instance, putting the thing "beside" a long
> horizontal space, and then rotating it.  The problem is that it doesn't
> rotate about a fixed point.  To see the problem, consider this program:
> (require 2htdp/image)
> (define a (beside (rectangle 150 2 "solid" "black") (ellipse 10 50 "solid"
> "purple")))
> (overlay/places "middle" "middle"
>                (rotate  0 a)
>                (rotate 20 a)
>                (rotate 40 a)
>                (rotate 60 a))
> The problem is that mapping a point in the pre-rotation shape to a point in
> the post-rotation shape is hard.
> ...
> After wrestling with this for quite a while, I have a solution of sorts; you
> have to overlay the shape you want to rotate on a large outline circle in
> such a way that the shape is entirely inside the circle. Rotating this shape
> does not change the bounding box at all, meaning that you can overlay them
> correctly. Needless to say, computing the size of the circle required is a
> big pain.
> E.G.:
> (define b (overlay/xy (circle 200 "outline" "blue") 200 200 a))
> (overlay
>  (rotate  0 b)
>  (rotate 20 b)
>  (rotate 40 b)
>  (rotate 60 b))
> Am I missing something obvious?
> John
> [*] with the obvious caveat that the old version didn't rotate shapes at
> all.

Posted on the dev mailing list.