Polygons & Nodal Points...
schoon at amgt.com
schoon at amgt.com
Mon Jul 16 12:55:55 CDT 2001
~sdpm~
Hey, thanks! Yes, I did think of this approach - simply check to see if
my node falls on a line... This will work if all lines are orthoganal,
but I can't be guaranteed this will be the case. The approach I'm
thinking of is like this:
All polygons start at the origin.
Start at origin X=0, Y=0;
If X == vertice, check for max/min Y and increment Y from min to max.
Increment X check max/min Y, increment Y from min to max....
My thoughts are this would handle angled line segments. What I'm doing
is creating a mesh within the polygon.... This is discussed somewhat in
the Mastering Algorithms book, but solving for the case of a node on a
vertice was out of the books scope.
.mark
>----------
>From: cabney[SMTP:cabney at cyberpass.net]
>Sent: Sunday, July 15, 2001 11:42 PM
>To: Mark Schoonover
>Cc: san-diego-pm-list at happyfunball.pm.org
>Subject: RE: Polygons & Nodal Points...
>
>~sdpm~
>On Sun, 15 Jul 2001 schoon at amgt.com wrote:
>
>> Yes, this is true, using a ray... But it fails when a point is right on
>> a boundary, and the polygon is odd shaped which would make an even
>> amount of crossings... Still a valid point, but fails the test...
>
>K, i have to admit... you need to handle when you are leaving the
>polyon and your y-value is on the edge:
>
>sub in_poly
>{
> # @isect are x,y quads from the polygon that cross at x
> my ($x, $y, @isect) = @_;
>
> return "hit!" if is_node($x,$y, at isect);
> my $c = 0;
>
> # slice gives you y at x for each x,y quad
> my @ladder = slice ($x, @isect);
> @ladder = sort {$a <=> $b} @ladder;
>
> while (@ladder)
> {
> my $rung = shift @ladder;
> if ( $y == $rung ) {
> unless ($c % 2) { $c-- }
> last;
> }
> last if ( $y < $rung );
> $c++;
> }
> return ($c % 2) ? "hit!" : "miss!";
>}
>
>CA
>--
>There was a time
>A wind that blew so young
>For this could be the biggest sky
>And I could have the faintest idea
>
>~sdpm~
>
>The posting address is: san-diego-pm-list at hfb.pm.org
>
>List requests should be sent to: majordomo at hfb.pm.org
>
>If you ever want to remove yourself from this mailing list,
>you can send mail to <majordomo at happyfunball.pm.org> with the following
>command in the body of your email message:
>
> unsubscribe san-diego-pm-list
>
>If you ever need to get in contact with the owner of the list,
>(if you have trouble unsubscribing, or have questions about the
>list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
>This is the general rule for most mailing lists when you need
>to contact a human.
>
>
>
~sdpm~
The posting address is: san-diego-pm-list at hfb.pm.org
List requests should be sent to: majordomo at hfb.pm.org
If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:
unsubscribe san-diego-pm-list
If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.
More information about the San-Diego-pm
mailing list