Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Logo > [LogoForum] Re:...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 1511 of 1588
Post > Topic >>

[LogoForum] Re: Graphing Utility

by "John St. Clair" <john.stclair@[EMAIL PROTECTED] > Jan 8, 2008 at 04:40 AM

The message below is being cross-posted from the LogoForum.  Please 
reply here at comp.lang.logo and it will be cross-posted back to the 
LogoForum.  The original author of this message is 
gene_sullivan@[EMAIL PROTECTED]
 In LogoForum@[EMAIL PROTECTED]
 "jbhnj1975" <jbhnj1975@[EMAIL PROTECTED]
> wrote:
>
> 
> 
> I would like to start with something simple like an xy plane graphing a 
> parabola as y=(+/-)x^2
> 
> Can I create a program (in Elica/Logo) that can solve and graph 
> equations?
> 
> I assume I would need to label the variables and put in limits.. 
> 
> Any ideas?

Sure.
If you're new to Logo but have the grounding in Cartesian coordinate
systems which the formulation of your question reveals, the turtle 
moves in the XY plane by default. So, whether you are aware of not,
all that is lacking for you to `see' it as such are a pair of axes.
Every logo implementation I'm aware of has a `home' command which
places the turtle at (0,0).

Though most graphics are done with `forward' and `back', one may
use Cartesian coordinates as well.
One may find out the position of the turtle (EG a `cursor', if you
think about it) with either:
pos
turtle.pos

One may set the turtle's position directly (without doing Penup
followed by a `forward' or `back') by
setpos [x y]
where x and y are what you'd expect.
Notice the lack of comma, though; whitespace separates them.
{aside: The square brackets are those of a Logo list.
So one can form a separate list as a variable then 
provide the name of the variable containing the list.
}

So, here is a little Elica program you should be able to copy 
and paste into either a new file or the command window:

;v--- sample code bounded by this line

clearscreen

home
print pos

setpos [10 10]
print pos

;^--- sample code bounded by this line

However, to make sure you see the values of X and Y 
which were printed out the print commands make sure
you have the `output' window visible.
This can be done with View -> Output
The position after `home' should be [0 0]
And the position of the turtle/graphics_cursor after 
setpos [10 10] should be [10 10], obviously.

Given that the coordinates used by `setpos' may
be variables, one may set up one or more loops
in which variables may be changed and applied to
the arguments/parameters list of `setpos'

Here is another sample to run:

;v--- sample #2 code bounded by this line

clearscreen

home
print pos

make "len 10
make "angle 5

rt 90 ; set heading down positive X axis
repeat 20 [
fd :len
lt :angle

make :len (:len + 3)
make :angle (:angle * 1.5)
]

;^--- sample #2 code bounded by this line

Note that this --^ used fd and lt to draw, using conventional
turtle geometry.
Elica refers to this mode of drawing as `traditionalturtle'
However one can generate points using the `point' command.
However this might require that one `run graphix' first, which
you might not want to dabble in yet. So I created this one
which uses `setpos'

;v--- sample #3 code bounded by this line

clearscreen

home
print pos

make "delta_x 5
make "delta_y 2
make "this_x :delta_x
make "this_y :delta_y

repeat 10 [
setpos (list :this_x :this_y)
print pos
make "this_x (:this_x + :delta_x + 3)
make "this_y ((:this_y + :delta_y) * 1.5)
]

;^--- sample #3 code bounded by this line

Though this produces something roughly parabolic, I'll 
leave the details of how you choose to graph your
parabola up to you.

I hope this helped in some way.

BTW. This group seems to be biased towards MSWLogo.
So you might get a better response from sending
Elica-specific questions to Elica's user group.
http://tech.groups.yahoo.com/group/elica/

Cheers!
Gene

__._,_.___

LogoForum messages are archived at: 
http://groups.yahoo.com/group/LogoForum




 1 Posts in Topic:
[LogoForum] Re: Graphing Utility
"John St. Clair"  2008-01-08 04:40:16 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon May 12 2:09:42 CDT 2008.