[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: [SUMMARY] Turtle Graphics (#104

email55555 email55555

12/7/2006 4:56:00 PM

> Most of those should be obvious implementations. The surprise, if any, comes
> from the fact that pen_down() puts a point on the track. This makes sense
> though, if you think about it. If you touch a pen to a piece of paper you have
> made a mark, even though you have not yet drawn a line. The Turtle should
> function the same way.

Well, using this way, it may create "invalid" segment.

By definition:
track ::= [segment, segment, ...] # drawing data
segment ::= [point, point, ...] # points to be joined by line segments
point ::= [x, y] # pair of floats

I was thinking a "no-empty" segment must have at least 2 points.
If we allow pen_down to make a mark, it may create invalid segment.
This test code shows:

home
pd # mark [0,0]
pu
fd 100
pd
right 90
fd 100
pu
p track # ==> [[[0.0, 0.0]], [[0.0, 100.0], [100.0, 100.0]]]

so [[0.0, 0.0]] is not a valid segment, it is just a "mark".
And the Tk-viewer even not show it as a "point".
( for drawing the point [0,0], it maybe a segment like [[0,0],[0,0]] ? )

Anyway, in case you write your own viewer,
if we accept "mark", you need to test the invalid segment.

1 Answer

James Gray

12/7/2006 8:55:00 PM

0

On Dec 7, 2006, at 10:56 AM, David Tran wrote:

>> Most of those should be obvious implementations. The surprise, if
>> any, comes
>> from the fact that pen_down() puts a point on the track. This
>> makes sense
>> though, if you think about it. If you touch a pen to a piece of
>> paper you have
>> made a mark, even though you have not yet drawn a line. The
>> Turtle should
>> function the same way.
>
> Well, using this way, it may create "invalid" segment.
>
> By definition:
> track ::= [segment, segment, ...] # drawing data
> segment ::= [point, point, ...] # points to be joined by line
> segments
> point ::= [x, y] # pair of floats
>
> I was thinking a "no-empty" segment must have at least 2 points.

Well a track with just one segment is legal so I assume a segment
with just one point is fine too. The code provided with the quiz
handles individual points, though it seems Morton and I took
different approaches as to how to handle them.

James Edward Gray II