[MWForum]Calling mathcats: geometry help please

Jeff Knope mwforum@lists.mathcats.com
Thu, 12 Aug 2004 21:09:10 -0700


This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C480B0.9C72DFB0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Daniel,

I seem to be having an unusually verbose day.

Turns out there is a bug. The culprit is: make "t2 (:d1x * :t1 + :x1x - =
:x2x) / :d2x

:d2x is :x3 - :x4, which is zero for a vertical segment. So you get a =
"can't divide by zero" message.

Trouble is, in my application, a vertical line will occur very =
frequently. But I still need to know the intersect location for it and =
some other segment. So I guess that condition should be trapped and =
dealt with some other way.

Any ideas?

Okay, I'm hanging it for today...--Jeff


----- Original Message -----=20
From: "Jeff Knope" <jknope@asis.com>
To: <mwforum@lists.mathcats.com>
Sent: Thursday, August 12, 2004 8:44 PM
Subject: Re: [MWForum]Calling mathcats: geometry help please


> Daniel,
>=20
> I made some minor revisions: changed the input format, set a flag =
"tag01 for
> if intersection is on segments (true) or not (false), removed all the
> drawing, and made it write intersection location and tag01 value to =
console.
>=20
> I kept your STARTUP that makes it run 40 times, each with 2 randomly
> generated segments. So running STARTUP repeatedly does lots of =
testing, and
> you can see all the results in the console.
>=20
> Here's the code as I have it now:
>=20
> to INTERSECT :pt1 :pt2 :pt3 :pt4
>=20
> make "tag01 "true
>=20
> make "x1 first :pt1
> make "y1 last :pt1
> make "x2 first :pt2
> make "y2 last :pt2
> make "x3 first :pt3
> make "y3 last :pt3
> make "x4 first :pt4
> make "y4 last :pt4
>=20
> make "d1x :x1 - :x2
> make "d1y :y1 - :y2
> make "d2x :x3 - :x4
> make "d2y :y3 - :y4
>=20
> make "x1x :x2
> make "x1y :y2
> make "x2x :x4
> make "x2y :y4
>=20
> make "c :d1x * :d2y - :d1y * :d2x
> if :c =3D 0 [output [PARALLEL]]
>=20
> make "t1 (:d2x * (:x1y - :x2y) + :d2y * (:x2x - :x1x)) / :c
> make "t2 (:d1x * :t1 + :x1x - :x2x) / :d2x
>=20
> if or :t1 > 1 :t1 < 0 [make "tag01 "false]
> if or :t2 > 1 :t2 < 0 [make "tag01 "false]
>=20
> output list list (:x1x + :d1x * :t1) (:x1y + :d1y * :t1) :tag01
> end
>=20
>=20
> to STARTUP
> repeat 40 [
> make "i INTERSECT pnt pnt pnt pnt
> show :i
> ]
> end
>=20
> to pnt
> op list 300 - random 600 300 - random 600
> end
>=20
> Thanks again for all your terrific help
> --Jeff
>=20
> ----- Original Message -----=20
> From: "Jeff Knope" <jknope@asis.com>
> To: <mwforum@lists.mathcats.com>
> Sent: Thursday, August 12, 2004 7:10 PM
> Subject: Re: [MWForum]Calling mathcats: geometry help please
>=20
>=20
> > Daniel,
> >
> > Thank you for the explanation of your procedure. I think I'm getting =
it.
> >
> > You said, "The maximum value for setpos is 9999." My point is your
> procedure
> > is purely mathmatical. There are not setpos operations used, at =
least not
> to
> > the intersections (recall I substitiuted show for the setpos you had =
at
> the
> > end). Since it's just number crunching, would it still reach an "out =
of
> > bounds" value?
> >
> > I really appreciate all your help with this.
> >
> > --Jeff
> >
> > ----- Original Message -----=20
> > From: "Daniel Ajoy" <dajoy@openworldlearning.org>
> > To: <mwforum@lists.mathcats.com>
> > Sent: Thursday, August 12, 2004 6:46 PM
> > Subject: Re: [MWForum]Calling mathcats: geometry help please
> >
> >
> > > On 12 Aug 2004 at 17:45, Jeff Knope wrote:
> > >
> > > > Daniel,
> > > >
> > > > I just commented out the two NOTAVAILABLE lines, and in startup =
I
> > replaced the setpos with show.
> > > >
> > > > It ran right through all 40 repeats without a hitch. I see your
> > projectsize is [744 426]. One value
> > > > shown was: [1617.52972259 -506.573051519].
> > > >
> > > > So it's fair to say it can handle working off the grid, so to =
speak.
> > Now, those two NOTAVAILABLE
> > > > tests can be used to decide how to set that tag (on segs or =
not),
> right?
> > >
> > > Right. Those two NOTAVAILABLE lines are the ones that control
> > > of the segments actually touch.
> > >
> > > > Do you see any problems
> > > > with any of this?
> > >
> > > I guess that if the lines almost parallel, but "c" is not actually =
0.
> > > then "t1" or "t2" could be "out of bounds"
> > >
> > > setpos list 1e500 1e500
> > > The maximum value for setpos is 9999
> > >
> > >
> > >
> > > Daniel
> > > OpenWorld Learning (OWL)
> > > http://mia.openworldlearning.org
> > >
> > >
> > >
> > > _______________________________________________
> > > MWForum mailing list
> > > MWForum@lists.mathcats.com
> > > http://lists.mathcats.com/mailman/listinfo/mwforum
> > > Attachments archived at:
> > > http://www.mathcats.com/mwforum/attachments.html
> > > To unsubscribe or for administrative questions contact
> > > mailto:mwforum-admin@lists.mathcats.com
> > >
> > >
> >
> > _______________________________________________
> > MWForum mailing list
> > MWForum@lists.mathcats.com
> > http://lists.mathcats.com/mailman/listinfo/mwforum
> > Attachments archived at:
> > http://www.mathcats.com/mwforum/attachments.html
> > To unsubscribe or for administrative questions contact
> > mailto:mwforum-admin@lists.mathcats.com
> >
> >
>=20
> _______________________________________________
> MWForum mailing list
> MWForum@lists.mathcats.com
> http://lists.mathcats.com/mailman/listinfo/mwforum
> Attachments archived at:
> http://www.mathcats.com/mwforum/attachments.html
> To unsubscribe or for administrative questions contact=20
> mailto:mwforum-admin@lists.mathcats.com
>=20
> 
------=_NextPart_000_0007_01C480B0.9C72DFB0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1458" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Daniel,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I seem to be&nbsp;having an unusually =
verbose=20
day.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Turns out there is a bug. The culprit =
is:=20
</FONT><FONT face=3DArial size=3D2>make "t2 (:d1x * :t1 + :x1x - :x2x) / =

:d2x</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>:d2x is :x3 - :x4, which is zero for a =
vertical=20
segment. So you get a "can't divide by zero" message.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Trouble is, in my application, a =
vertical line will=20
occur very frequently. But I still need to know the =
intersect&nbsp;location for=20
it and some other segment.&nbsp;So I guess that condition should be =
trapped and=20
dealt with some other way.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Any ideas?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Okay, I'm hanging it for=20
today...--Jeff</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>----- Original Message ----- </FONT>
<DIV><FONT face=3DArial size=3D2>From: "Jeff Knope" &lt;</FONT><A=20
href=3D"mailto:jknope@asis.com"><FONT face=3DArial=20
size=3D2>jknope@asis.com</FONT></A><FONT face=3DArial =
size=3D2>&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>To: &lt;</FONT><A=20
href=3D"mailto:mwforum@lists.mathcats.com"><FONT face=3DArial=20
size=3D2>mwforum@lists.mathcats.com</FONT></A><FONT face=3DArial=20
size=3D2>&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Sent: Thursday, August 12, 2004 8:44=20
PM</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Subject: Re: [MWForum]Calling mathcats: =
geometry=20
help please</FONT></DIV></DIV>
<DIV><FONT face=3DArial><BR><FONT size=3D2></FONT></FONT></DIV><FONT =
face=3DArial=20
size=3D2>&gt; Daniel,<BR>&gt; <BR>&gt; I made some minor revisions: =
changed the=20
input format, set a flag "tag01 for<BR>&gt; if intersection is on =
segments=20
(true) or not (false), removed all the<BR>&gt; drawing, and made it =
write=20
intersection location and tag01 value to console.<BR>&gt; <BR>&gt; I =
kept your=20
STARTUP that makes it run 40 times, each with 2 randomly<BR>&gt; =
generated=20
segments. So running STARTUP repeatedly does lots of testing, =
and<BR>&gt; you=20
can see all the results in the console.<BR>&gt; <BR>&gt; Here's the code =
as I=20
have it now:<BR>&gt; <BR>&gt; to INTERSECT :pt1 :pt2 :pt3 :pt4<BR>&gt; =
<BR>&gt;=20
make "tag01 "true<BR>&gt; <BR>&gt; make "x1 first :pt1<BR>&gt; make "y1 =
last=20
:pt1<BR>&gt; make "x2 first :pt2<BR>&gt; make "y2 last :pt2<BR>&gt; make =
"x3=20
first :pt3<BR>&gt; make "y3 last :pt3<BR>&gt; make "x4 first =
:pt4<BR>&gt; make=20
"y4 last :pt4<BR>&gt; <BR>&gt; make "d1x :x1 - :x2<BR>&gt; make "d1y :y1 =
-=20
:y2<BR>&gt; make "d2x :x3 - :x4<BR>&gt; make "d2y :y3 - :y4<BR>&gt; =
<BR>&gt;=20
make "x1x :x2<BR>&gt; make "x1y :y2<BR>&gt; make "x2x :x4<BR>&gt; make =
"x2y=20
:y4<BR>&gt; <BR>&gt; make "c :d1x * :d2y - :d1y * :d2x<BR>&gt; if :c =3D =
0 [output=20
[PARALLEL]]<BR>&gt; <BR>&gt; make "t1 (:d2x * (:x1y - :x2y) + :d2y * =
(:x2x -=20
:x1x)) / :c<BR>&gt; make "t2 (:d1x * :t1 + :x1x - :x2x) / :d2x<BR>&gt; =
<BR>&gt;=20
if or :t1 &gt; 1 :t1 &lt; 0 [make "tag01 "false]<BR>&gt; if or :t2 &gt; =
1 :t2=20
&lt; 0 [make "tag01 "false]<BR>&gt; <BR>&gt; output list list (:x1x + =
:d1x *=20
:t1) (:x1y + :d1y * :t1) :tag01<BR>&gt; end<BR>&gt; <BR>&gt; <BR>&gt; to =

STARTUP<BR>&gt; repeat 40 [<BR>&gt; make "i INTERSECT pnt pnt pnt =
pnt<BR>&gt;=20
show :i<BR>&gt; ]<BR>&gt; end<BR>&gt; <BR>&gt; to pnt<BR>&gt; op list =
300 -=20
random 600 300 - random 600<BR>&gt; end<BR>&gt; <BR>&gt; Thanks again =
for all=20
your terrific help<BR>&gt; --Jeff<BR>&gt; <BR>&gt; ----- Original =
Message -----=20
<BR>&gt; From: "Jeff Knope" &lt;</FONT><A =
href=3D"mailto:jknope@asis.com"><FONT=20
face=3DArial size=3D2>jknope@asis.com</FONT></A><FONT face=3DArial =
size=3D2>&gt;<BR>&gt;=20
To: &lt;</FONT><A href=3D"mailto:mwforum@lists.mathcats.com"><FONT =
face=3DArial=20
size=3D2>mwforum@lists.mathcats.com</FONT></A><FONT face=3DArial =
size=3D2>&gt;<BR>&gt;=20
Sent: Thursday, August 12, 2004 7:10 PM<BR>&gt; Subject: Re: =
[MWForum]Calling=20
mathcats: geometry help please<BR>&gt; <BR>&gt; <BR>&gt; &gt; =
Daniel,<BR>&gt;=20
&gt;<BR>&gt; &gt; Thank you for the explanation of your procedure. I =
think I'm=20
getting it.<BR>&gt; &gt;<BR>&gt; &gt; You said, "The maximum value for =
setpos is=20
9999." My point is your<BR>&gt; procedure<BR>&gt; &gt; is purely =
mathmatical.=20
There are not setpos operations used, at least not<BR>&gt; to<BR>&gt; =
&gt; the=20
intersections (recall I substitiuted show for the setpos you had =
at<BR>&gt;=20
the<BR>&gt; &gt; end). Since it's just number crunching, would it still =
reach an=20
"out of<BR>&gt; &gt; bounds" value?<BR>&gt; &gt;<BR>&gt; &gt; I really=20
appreciate all your help with this.<BR>&gt; &gt;<BR>&gt; &gt; =
--Jeff<BR>&gt;=20
&gt;<BR>&gt; &gt; ----- Original Message ----- <BR>&gt; &gt; From: =
"Daniel Ajoy"=20
&lt;</FONT><A href=3D"mailto:dajoy@openworldlearning.org"><FONT =
face=3DArial=20
size=3D2>dajoy@openworldlearning.org</FONT></A><FONT face=3DArial=20
size=3D2>&gt;<BR>&gt; &gt; To: &lt;</FONT><A=20
href=3D"mailto:mwforum@lists.mathcats.com"><FONT face=3DArial=20
size=3D2>mwforum@lists.mathcats.com</FONT></A><FONT face=3DArial =
size=3D2>&gt;<BR>&gt;=20
&gt; Sent: Thursday, August 12, 2004 6:46 PM<BR>&gt; &gt; Subject: Re:=20
[MWForum]Calling mathcats: geometry help please<BR>&gt; &gt;<BR>&gt;=20
&gt;<BR>&gt; &gt; &gt; On 12 Aug 2004 at 17:45, Jeff Knope =
wrote:<BR>&gt; &gt;=20
&gt;<BR>&gt; &gt; &gt; &gt; Daniel,<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; =
&gt;=20
&gt; I just commented out the two NOTAVAILABLE lines, and in startup =
I<BR>&gt;=20
&gt; replaced the setpos with show.<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; =
&gt;=20
&gt; It ran right through all 40 repeats without a hitch. I see =
your<BR>&gt;=20
&gt; projectsize is [744 426]. One value<BR>&gt; &gt; &gt; &gt; shown =
was:=20
[1617.52972259 -506.573051519].<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; =
&gt; So=20
it's fair to say it can handle working off the grid, so to =
speak.<BR>&gt; &gt;=20
Now, those two NOTAVAILABLE<BR>&gt; &gt; &gt; &gt; tests can be used to =
decide=20
how to set that tag (on segs or not),<BR>&gt; right?<BR>&gt; &gt; =
&gt;<BR>&gt;=20
&gt; &gt; Right. Those two NOTAVAILABLE lines are the ones that =
control<BR>&gt;=20
&gt; &gt; of the segments actually touch.<BR>&gt; &gt; &gt;<BR>&gt; &gt; =
&gt;=20
&gt; Do you see any problems<BR>&gt; &gt; &gt; &gt; with any of =
this?<BR>&gt;=20
&gt; &gt;<BR>&gt; &gt; &gt; I guess that if the lines almost parallel, =
but "c"=20
is not actually 0.<BR>&gt; &gt; &gt; then "t1" or "t2" could be "out of=20
bounds"<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; setpos list 1e500 =
1e500<BR>&gt; &gt;=20
&gt; The maximum value for setpos is 9999<BR>&gt; &gt; &gt;<BR>&gt; &gt; =

&gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; Daniel<BR>&gt; &gt; &gt; =
OpenWorld=20
Learning (OWL)<BR>&gt; &gt; &gt; </FONT><A=20
href=3D"http://mia.openworldlearning.org"><FONT face=3DArial=20
size=3D2>http://mia.openworldlearning.org</FONT></A><BR><FONT =
face=3DArial=20
size=3D2>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; =
&gt;=20
_______________________________________________<BR>&gt; &gt; &gt; =
MWForum=20
mailing list<BR>&gt; &gt; &gt; </FONT><A=20
href=3D"mailto:MWForum@lists.mathcats.com"><FONT face=3DArial=20
size=3D2>MWForum@lists.mathcats.com</FONT></A><BR><FONT face=3DArial =
size=3D2>&gt;=20
&gt; &gt; </FONT><A=20
href=3D"http://lists.mathcats.com/mailman/listinfo/mwforum"><FONT =
face=3DArial=20
size=3D2>http://lists.mathcats.com/mailman/listinfo/mwforum</FONT></A><BR=
><FONT=20
face=3DArial size=3D2>&gt; &gt; &gt; Attachments archived at:<BR>&gt; =
&gt; &gt;=20
</FONT><A =
href=3D"http://www.mathcats.com/mwforum/attachments.html"><FONT=20
face=3DArial=20
size=3D2>http://www.mathcats.com/mwforum/attachments.html</FONT></A><BR><=
FONT=20
face=3DArial size=3D2>&gt; &gt; &gt; To unsubscribe or for =
administrative questions=20
contact<BR>&gt; &gt; &gt; </FONT><A=20
href=3D"mailto:mwforum-admin@lists.mathcats.com"><FONT face=3DArial=20
size=3D2>mailto:mwforum-admin@lists.mathcats.com</FONT></A><BR><FONT =
face=3DArial=20
size=3D2>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;=20
_______________________________________________<BR>&gt; &gt; MWForum =
mailing=20
list<BR>&gt; &gt; </FONT><A =
href=3D"mailto:MWForum@lists.mathcats.com"><FONT=20
face=3DArial size=3D2>MWForum@lists.mathcats.com</FONT></A><BR><FONT =
face=3DArial=20
size=3D2>&gt; &gt; </FONT><A=20
href=3D"http://lists.mathcats.com/mailman/listinfo/mwforum"><FONT =
face=3DArial=20
size=3D2>http://lists.mathcats.com/mailman/listinfo/mwforum</FONT></A><BR=
><FONT=20
face=3DArial size=3D2>&gt; &gt; Attachments archived at:<BR>&gt; &gt; =
</FONT><A=20
href=3D"http://www.mathcats.com/mwforum/attachments.html"><FONT =
face=3DArial=20
size=3D2>http://www.mathcats.com/mwforum/attachments.html</FONT></A><BR><=
FONT=20
face=3DArial size=3D2>&gt; &gt; To unsubscribe or for administrative =
questions=20
contact<BR>&gt; &gt; </FONT><A=20
href=3D"mailto:mwforum-admin@lists.mathcats.com"><FONT face=3DArial=20
size=3D2>mailto:mwforum-admin@lists.mathcats.com</FONT></A><BR><FONT =
face=3DArial=20
size=3D2>&gt; &gt;<BR>&gt; &gt;<BR>&gt; <BR>&gt;=20
_______________________________________________<BR>&gt; MWForum mailing=20
list<BR>&gt; </FONT><A href=3D"mailto:MWForum@lists.mathcats.com"><FONT =
face=3DArial=20
size=3D2>MWForum@lists.mathcats.com</FONT></A><BR><FONT face=3DArial =
size=3D2>&gt;=20
</FONT><A =
href=3D"http://lists.mathcats.com/mailman/listinfo/mwforum"><FONT=20
face=3DArial=20
size=3D2>http://lists.mathcats.com/mailman/listinfo/mwforum</FONT></A><BR=
><FONT=20
face=3DArial size=3D2>&gt; Attachments archived at:<BR>&gt; </FONT><A=20
href=3D"http://www.mathcats.com/mwforum/attachments.html"><FONT =
face=3DArial=20
size=3D2>http://www.mathcats.com/mwforum/attachments.html</FONT></A><BR><=
FONT=20
face=3DArial size=3D2>&gt; To unsubscribe or for administrative =
questions contact=20
<BR>&gt; </FONT><A =
href=3D"mailto:mwforum-admin@lists.mathcats.com"><FONT=20
face=3DArial =
size=3D2>mailto:mwforum-admin@lists.mathcats.com</FONT></A><BR><FONT=20
face=3DArial size=3D2>&gt; <BR>&gt; </FONT></BODY></HTML>

------=_NextPart_000_0007_01C480B0.9C72DFB0--