[MWForum]Calling mathcats: geometry help please
Jeff Knope
mwforum@lists.mathcats.com
Thu, 12 Aug 2004 20:44:01 -0700
Daniel,
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.
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.
Here's the code as I have it now:
to INTERSECT :pt1 :pt2 :pt3 :pt4
make "tag01 "true
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
make "d1x :x1 - :x2
make "d1y :y1 - :y2
make "d2x :x3 - :x4
make "d2y :y3 - :y4
make "x1x :x2
make "x1y :y2
make "x2x :x4
make "x2y :y4
make "c :d1x * :d2y - :d1y * :d2x
if :c = 0 [output [PARALLEL]]
make "t1 (:d2x * (:x1y - :x2y) + :d2y * (:x2x - :x1x)) / :c
make "t2 (:d1x * :t1 + :x1x - :x2x) / :d2x
if or :t1 > 1 :t1 < 0 [make "tag01 "false]
if or :t2 > 1 :t2 < 0 [make "tag01 "false]
output list list (:x1x + :d1x * :t1) (:x1y + :d1y * :t1) :tag01
end
to STARTUP
repeat 40 [
make "i INTERSECT pnt pnt pnt pnt
show :i
]
end
to pnt
op list 300 - random 600 300 - random 600
end
Thanks again for all your terrific help
--Jeff
----- Original Message -----
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
> 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 -----
> 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
>
>