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