# Re: Turtle Graphics (#104)

**URL:** <https://www.ruby-forum.com/t/re-turtle-graphics-104/78661>\
**Category:** Ruby\
**Created:** [December 7, 2006, 5:57pm UTC](https://www.ruby-forum.com/t/re-turtle-graphics-104/78661 "2006-12-07T17:57:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidtl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/35a633/32.png) [@davidtl](https://www.ruby-forum.com/u/davidtl)\
**Post date:** [December 7, 2006, 5:57pm UTC](https://www.ruby-forum.com/t/re-turtle-graphics-104/78661/1 "2006-12-07T17:57:51Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![davidtl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/35a633/32.png) [@davidtl](https://www.ruby-forum.com/u/davidtl)\
**Post date:** [December 7, 2006, 9:57pm UTC](https://www.ruby-forum.com/t/re-turtle-graphics-104/78661/2 "2006-12-07T21:57:00Z")

</div>

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

> 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 G. II
