[Squeakland] Discovering Pi in Squeak

subbukk subbukk at gmail.com
Thu May 31 13:15:37 PDT 2007


On Thursday 31 May 2007 6:18 pm, Alan Kay wrote:
> Hi Subbu --
>
> And of course Pi is not at all required for "turn by" or "forward".
> It is one of many constants in the init method for float but is not
> needed for these behaviors. "foo turn by ang" is easily written in
> Etoys as "foo heading increase by ang" where "heading" is a simple
> property, so there is no Pi involved here. "foo forward by 5" is more
> complicated (because it involves a vector addition to foo's location)
> but still requires no Pi.
It is true that turn: just sets the heading and doesn't use Pi. But the 
heading gets used in forward operation which uses degreesToRadians from Float 
class which ends up using Pi. The x and y offsets are computed using sin/cos 
primitive functions whose computations, I suspect, would have used Pi. 
Therefore, the diameter computed as (xmax - xmin) would have used Pi. I just 
assumed the worst case :-).

The forward/turn method is same as triangular approximation when the turn 
angle is a factor of 360. A child who happens to chose 7 (3.176) will wonder 
why those who chose 8 (3.143) or 6 (3.141) have closer results. Triangular 
approximation is self-correcting. The error isnt significant for angles below 
5, so this aspect is of academic interest only.

Anyway, the idea behind triangular approximation is to let kids learn that 
there are named numbers (pi, e) whose values are approximated unlike named 
numbers like half, quarter etc.

I noticed something strange about the numbers calculated by Squeak. The ratio 
of perimeter of inscribed polygon to diameter should be less than Pi. But for 
turns of 10 degrees (3.150) and 8 degrees (3.143) I get overshoots.

Regards .. Subbu


More information about the Squeakland mailing list