[MWForum]Elliptical orbits for planets
Mike Sandy
mwforum@lists.mathcats.com
Sat, 8 Mar 2003 13:08:31 -0000
Dale wrote:
> > The usual method for making an elliptical shaped flower bed in the
garden
>> is to use 3 sticks and a piece of string.
>
> That is what I am attempting to do with MSWLogo. Does not work for all
> flower bed locations and there are no doubt other problems I have not
> discovered yet. Also I want the turtle to stop after the ellipse is
> finished.
The way I used to stop the plot was to determine when the plotting turtle
had
rotated thro' 360°.
For each point determine the heading (h) of the line joining the previous
point to the point. If the tangent at the starting point has a heading h0,
then stop when h-h0>360°.
The problem is that heading values are reduced modulo 360,
so for h0=10°(say), h-h0 is positive up to h=359.9999.., negative
from h=0, then positive once it has passed h0.
So you need to detect h-h0>0 the second time round.
Use a flag, f. and start with f=0
ifelse :f = 0
[if (heading - :h0) < 0
[make "f 1]]
[if (heading - :h0) > 0[stop]]
The method I used in my (previous) attachment program is more complicated.
By using a "scout" turtle to find the next point the heading of the plotting
turtle will be the h used above - since the segment is plotted by moving
towards the position found by the "scout".
The simplest position to start the plot is a point on the ellipse along the
line of the foci. The tangent is perpendicular to that line.
Mike