Home Project Folders Resources How Do I? MWForum
Site Map Search Our Team

MWForum Message [Date Index] [Threads] [Authors] [Attachments] [Subscribe]

[Thread Prev] [Thread Next]

Subject: Circle and arc help
From: mwforum@xxxxxxxxxxxxxxxxxx (David Longman)
Date: Sun, 20 Feb 2005 17:53:25 -0000

Another circle solution. This one treats the Turtle more like a robot than a
graphics pen.
 
No trigonometry at all! 
 
(Using MSWLogo)
 
Here is version 1:
to crawl                           
if (distance :c) < :r [lt 1]   ;if too close to centre of object turn away
if (distance :c) > :r [rt 1]   ;if too far from centre turn towards
fd 1
crawl
end
 
Where
:c is the centre of the object (i.e. the circle)
:r is the size of the object (i.e. the radius)
In this procedure the Turtle checks its distance from the centre of the
object. Assuming that the Turtle is travelling in a clockwise direction, the
Turtle turns LEFT if it is too close so as to move away from the object. If it
is too far from the centre the Turtle turns RIGHT so as to move towards it. 
NOTE that for this procedure to produce a circle the turtle must be positioned
appropriately. For example this line will draw a circle:
 
CS PU FD :R RT 90 PD CRAWL


NOTE the use of RT 90 to orient the Turtle appropriately. What happens if you
use LT 90 instead? What happens if you use RT 30? Try swapping the use of LT
and RT inside the procedure.
 
Varying the starting point also produces some beautiful and interesting
effects.
 
What happens if you start CRAWL without moving the Turtle from the centre? 
 
What happens if you start CRAWL further out? E.g.
 
CS PU FD :R+50 RT 90 PD CRAWL
 
The procedure can be made more flexible by the use of more variables:
 
to crawl
if (distance :c) < :r [lt :a]
if (distance :c) > :r [rt :a]
fd :step
crawl
end
 
The following are sample values :
 
Make "c [100 100]
Make "r 100
Make "a 1
Make "step 1
 
A start line like the following would position the Turtle appropriately before
beginning CRAWL:
­cs pu setpos :c fd :r rt 90 pd crawl 
Experiment with these variables.
CRAWL can written in a slightly different way in order to maintain a constant
distance.
This example is named ORBIT:
to orbit
seth towards :c                                   ;face towards centre
localmake "move ((distance :c) - :r)   ;calculate error
pu fd :move                                         ;move towards or away from
centre
rt 90 pd fd :step                                   ;orient and draw
orbit
end
In this procedure the Turtle uses a simple strategy to ensure a constant
distance from the centre. The initial position of the Turtle is irrelevant -
this procedure always finds the right starting point.
 
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
David Longman, Senior Lecturer in ICT
School of Education University of Wales, Newport
Caerleon Campus, PO Box 179
Newport
South Wales NP18 3YG
Tel: +44 (0)1633 432629
Fax: +44 (0)1633 432074
Web site: http://education.newport.ac.uk 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

________________________________

From: mwforum-admin@xxxxxxxxxxxxxxxxxx on behalf of Jacques Mathil
Sent: Fri 18/02/2005 2:27 PM
To: mwforum@xxxxxxxxxxxxxxxxxx
Subject: Re: [MWForum]Circle and arc help


Hello,
here is another solution. This procedure draws a centered polygon :
 
to centered_polygon :number_sides :radius
make "alpha 360 / :number_sides
make "side 2 * :radius * sin (:alpha / 2)
pu
fd :radius
rt 90 + :alpha / 2
pd
repeat :number_sides [fd :side rt :alpha]
pu
left 90 + :alpha / 2
bk :radius
end
 
it uses some trigonometrics not for young children, but you can use it as a
tool.
To obtain a circle, try many sides :   b.e  centered_polygon 90 100
you could modify this procedure to obtain arcs.
 
<-- Some tricks-->
to fig1 :r
if :r > 150 [stop]
centered_polygon 90 :r
fig1 :r + 20
end
 
to fig2 :r
if :r > 150 [stop]
centered_polygon 3 :r
rt 10
fig2 :r + 5
end
 
to fig3 :r
if :r > 150 [stop]
centered_polygon 90 :r
rt 20 fd 8
fig3 :r + 3
end
 
Try them like this : fig1 0     fig2 0     fig3 0
 
Jacques Mathil
Chemin de la Moniasse 7
1254 Jussy
GENEVA  SWITZERLAND
Tél.  : +41 22 759 81 81
	----- Original Message ----- 
	From: Susan Einhorn <mailto:susan@xxxxxxx>  
	To: mwforum@xxxxxxxxxxxxxxxxxx 
	Sent: Thursday, February 17, 2005 5:14 PM
	Subject: RE: [MWForum]Circle and arc help

	This has been a great discussion on how to create different procedures to
draw a circle. This is a great challenge for students. Here's another
circle-drawing procedure from a new book about Math and MicroWorlds that's
being developed by LCSI  (authored by Wendy Petti):
	 
	to circle
	pu
	repeat 360 [  fd 50 pd fd 0 pu bk 50 rt 1]
	end
	 
	With an input:
	to circle :r
	pu
	repeat 360 [fd :r pd fd 0 pu bk :r rt 1]
	end
	 
	If you're not familiar with the pd fd 0 trick, it creates a dot without
displacing the turtle. If the radius for this circle is too large, there are
gaps between the dots in the circumference. To make the dots closer together
decrease the size of the turn (e.g., rt 1 / 2)and increase the input to repeat
accordingly (repeat 360 * 2).
	 
	That makes three (or four, although the old Apple Logo method is a variation
of Shawn's method) different ways to draw a circle.  If you think about it,
I'm sure you could come up with even more.

              
	Susan
	-------------------------------
	Susan Einhorn
	LCSI
	www.MicroWorlds.com
	susan@xxxxxxx
	 

                               
	-----Original Message-----
	From: mwforum-admin@xxxxxxxxxxxxxxxxxx [mailto:mwforum-admin@xxxxxxxxxxxxxxxxxx]On Behalf Of Logo Computer Systems Inc.
	Sent: Thursday, February 17, 2005 10:34 AM
	To: mwforum@xxxxxxxxxxxxxxxxxx
	Subject: Re: [MWForum]Circle and arc help
	 
	Hi!
	Could you program the circle with a variable (or 2) to make it easy to make
different sized circles? And how about the arc?
	Would the spell checker from  MSWord work with Pro or EX on  Mac OS 10)?
	 
	Hi Kate,
	 
	I used the following procedure in a -tools-.txt file and was able to create
different sized circles.
	 
	to cir :r
	repeat 360 [fd 2 * pi * :r / 360 rt 1]
	end
	Unfortunately, the spell checker features are only included with Windows
versions of Pro and EX.  I used to use an OS 9 application called, SpellTools
which is available at no charge for download from the following address:
http://mac.softpedia.com/progDownload/SpellTools-Download-1097.html   It's a
universal spell checker that works with all of your text oriented
applications.  I have never tried it under OS X.
	 
	Regards.
	 
	Shawn
	 
	-- 
	 
	Logo Computer Systems Inc.
	1 Westmount Square, Suite 300
	Montreal,QC  Canada
	H3Z 2P9
	info@xxxxxxx
	www.lcsi.ca
Title: Re: [MWForum]Circle and arc help
Another circle solution. This one treats the Turtle more like a robot than a graphics pen.
 
No trigonometry at all!
 
(Using MSWLogo)
 
Here is version 1:

to crawl                           

if (distance :c) < :r [lt 1]   ;if too close to centre of object turn away

if (distance :c) > :r [rt 1]   ;if too far from centre turn towards

fd 1

crawl

end

 

Where

:c is the centre of the object (i.e. the circle)

:r is the size of the object (i.e. the radius)

In this procedure the Turtle checks its distance from the centre of the object. Assuming that the Turtle is travelling in a clockwise direction, the Turtle turns LEFT if it is too close so as to move away from the object. If it is too far from the centre the Turtle turns RIGHT so as to move towards it.

NOTE that for this procedure to produce a circle the turtle must be positioned appropriately. For example this line will draw a circle:

 

CS PU FD :R RT 90 PD CRAWL

NOTE the use of RT 90 to orient the Turtle appropriately. What happens if you use LT 90 instead? What happens if you use RT 30? Try swapping the use of LT and RT inside the procedure.

 

Varying the starting point also produces some beautiful and interesting effects.

 

What happens if you start CRAWL without moving the Turtle from the centre?

 

What happens if you start CRAWL further out? E.g.

 

CS PU FD :R+50 RT 90 PD CRAWL

 

The procedure can be made more flexible by the use of more variables:

 

to crawl

if (distance :c) < :r [lt :a]

if (distance :c) > :r [rt :a]

fd :step

crawl

end

 

The following are sample values :

 

Make “c [100 100]

Make “r 100

Make “a 1

Make “step 1

 

A start line like the following would position the Turtle appropriately before beginning CRAWL:

­cs pu setpos :c fd :r rt 90 pd crawl

Experiment with these variables.

CRAWL can written in a slightly different way in order to maintain a constant distance.

This example is named ORBIT:

to orbit

seth towards :c                                   ;face towards centre

localmake "move ((distance :c) - :r)   ;calculate error

pu fd :move                                         ;move towards or away from centre

rt 90 pd fd :step                                   ;orient and draw

orbit

end

In this procedure the Turtle uses a simple strategy to ensure a constant distance from the centre. The initial position of the Turtle is irrelevant - this procedure always finds the right starting point.

 
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Longman, Senior Lecturer in ICT
School of Education University of Wales, Newport
Caerleon Campus, PO Box 179
Newport
South Wales NP18 3YG
Tel: +44 (0)1633 432629
Fax: +44 (0)1633 432074
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RE>


tabIndex=-1> From: > mwforum-admin@xxxxxxxxxxxxxxxxxx on behalf of Jacques > Mathil
Sent: Fri 18/02/2005 2:27 PM
To: > mwforum@xxxxxxxxxxxxxxxxxx
Subject: Re: [MWForum]Circle and arc help

Hello,
here is another solution. This procedure draws a centered polygon :
 
to
centered_polygon :number_sides :radius
make "alpha 360 /
:number_sides
make "side 2 * :radius * sin (:alpha /
2)
pu
fd :radius
rt 90 + :alpha /
2
pd
repeat :number_sides [fd :side rt
:alpha]
pu
left 90 + :alpha / 2
bk
:radius
end
 
it uses some trigonometrics not for young children, but you can use it as a tool.
To obtain a circle, try many sides :   b.e  centered_polygon 90 100
you could modify this procedure to obtain arcs.
 
<-- Some
tricks-->
to fig1 :r
if :r > 150
[stop]
centered_polygon 90 :r
fig1 :r +
20
end
 
to fig2 :r
if :r >
150 [stop]
centered_polygon 3 :r
rt 10
fig2 :r +
5
end
 
to fig3 :r
if :r > 150
[stop]
centered_polygon 90 :r
rt 20 fd 8
fig3 :r
+ 3
end
 
Try them like this : fig1 0     fig2 0     fig3 0
 
Jacques Mathil
Chemin de la Moniasse 7
1254 Jussy
GENEVA  SWITZERLAND
Tél.  : +41 22 759 81 81
----- Original Message -----
Sent: Thursday, February 17, 2005 5:14 PM
Subject: RE: [MWForum]Circle and arc help

This has been a great discussion on how to create different procedures to draw a circle. This is a great challenge for students. Here’s another circle-drawing procedure from a new book about Math and MicroWorlds that’s being developed by LCSI  (authored by Wendy Petti):

 

to circle

pu

repeat 360 [  fd 50 pd fd 0 pu bk 50 rt 1]

end

 

With an input:

to circle :r

pu

repeat 360 [fd :r pd fd 0 pu bk :r rt 1]

end

 

If you’re not familiar with the pd fd 0 trick, it creates a dot without displacing the turtle. If the radius for this circle is too large, there are gaps between the dots in the circumference. To make the dots closer together decrease the size of the turn (e.g., rt 1 / 2)and increase the input to repeat accordingly (repeat 360 * 2).

 

That makes three (or four, although the old Apple Logo method is a variation of Shawn’s method) different ways to draw a circle.  If you think about it, I’m sure you could come up with even more.

                                                                                           

Susan

-------------------------------

Susan Einhorn

LCSI

www.MicroWorlds.com

susan@xxxxxxx

 

                                                                                                            

-----Original Message-----
From: mwforum-admin@xxxxxxxxxxxxxxxxxx [mailto:mwforum-admin@xxxxxxxxxxxxxxxxxx]On Behalf Of Logo Computer Systems Inc.
Sent: Thursday, February 17, 2005 10:34 AM
To: mwforum@xxxxxxxxxxxxxxxxxx
Subject: Re: [MWForum]Circle and arc help

 

Hi!
Could you program the circle with a variable (or 2) to make it easy to make different sized circles? And how about the arc?

Would the spell checker from  MSWord work with Pro or EX on  Mac OS 10)?

 

Hi Kate,

 

I used the following procedure in a -tools-.txt file and was able to create different sized circles.

 

to cir :r
repeat 360 [fd 2 * pi * :r / 360 rt 1]

end

Unfortunately, the spell checker features are only included with Windows versions of Pro and EX.  I used to use an OS 9 application called, SpellTools which is available at no charge for download from the following address: http://mac.softpedia.com/progDownload/SpellTools-Download-1097.html   It's a universal spell checker that works with all of your text oriented applications.  I have never tried it under OS X.

 

Regards.

 

Shawn

 

-- 

 

Logo Computer Systems Inc.
1 Westmount Square, Suite 300
Montreal,QC  Canada
H3Z 2P9
info@xxxxxxx
www.lcsi.ca


  • Previous by thread: Circle and arc help
  • Next by thread: Circle and arc help

  • To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.


    © copyright 2001 - 2006