comp.lang.ada
 help / color / mirror / Atom feed
From: mikeg2@my-dejanews.com
Subject: Re: geometric utilities
Date: 1998/06/05
Date: 1998-06-05T00:00:00+00:00	[thread overview]
Message-ID: <6l7roc$h2l$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 6l6ihi$ivh$1@nnrp1.dejanews.com


Probably to my detriment, I've continued to try variations rather
than post what I've got so far - but, I'm really starting to
wonder if the algorithm actually works in all cases.

First, I think the lp.p1 := p[i] and lp.p2 := p[i] on line 10 (I
think that's where it was) is intentional per the text - i.e., ignore
*points* that are on the test line.  As it turns out, the intersect
procedure provided in the book doesn't appear to work in this case
(i.e., a point and a line) maybe because my stuff is floating point.
At any rate, I fixed this so that my code does properly detect
intersection of the test line with the ith point.

Using polygon ((1.0, 0.0), (0.0, 1.0), (-1.0, 0.0), (0.0, -1.0))
(a square around 0.0 on a 45 degree angle), and test point (0.0, 0.9),
the algorithm just doesn't seem to work, even when I do it by hand.
Maybe has something to do with j happening to start out at point
3 since point 4 passes the anchor rule (smallest x coordinate among
points with smallest y coordinate).  Point 3 happens to be collinear
with the test line...

Tomorrow I will post my code (not trying to be coy, I just have no way
here at home to get it from my laptop to my PC) - but was hoping in the
meantime someone might have taken a good look at the algorithm.  I did,
by the way, check with Addison Wesley for an errata sheet and sent a
note to Dr. Sedgewick to see if per chance there was a known problem
with the algorithm - but couldn't find anything and haven't yet heard
back from the good Doctor.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading




  reply	other threads:[~1998-06-05  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-04  0:00 geometric utilities mikeg2
1998-06-05  0:00 ` mikeg2 [this message]
1998-06-05  0:00 ` Brian Rogoff
1998-06-12  0:00   ` mikeg2
  -- strict thread matches above, loose matches on Subject: below --
1998-06-03  0:00 mikeg2
1998-06-03  0:00 ` Brian Rogoff
1998-06-04  0:00   ` Michael F Brenner
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox