more RE: Polygons & Nodal Points...

schoon at amgt.com schoon at amgt.com
Wed Jul 25 15:22:27 CDT 2001


~sdpm~
Thanks for all the ideas on this one.. It has kept my brain tied up for
a while! Caused major problems during the tutorials @ TPC5..... Had a
blast! I've actually thought of an easier way to determine if a point is
inside the polygon.... It looks like set theory to the rescue!! My idea
is to create a grid using the dimensions of the subelements as one set
of points. Then, using the vertices of the polygon as the second set,
determine which points are outside the polygon - IE simply not in the
union set of points.... Gotta check maperl, but it might be easier this
way.... Two more simple changes to current projects and I can spend some
time with the book....

.mark

>----------
>From: 	cabney[SMTP:cabney at cyberpass.net]
>Sent: 	Wednesday, July 25, 2001 1:02 PM
>To: 	Mark Schoonover
>Cc: 	san-diego-pm-list at happyfunball.pm.org
>Subject: 	more RE: Polygons & Nodal Points...
>
>I can't leave this alone (I have a GD cgi script for visualization :-)
>
>Some refactoring of the in_poly subroutine...
>
>On Mon, 16 Jul 2001, cabney wrote:
>> ###
>> # is a point x,y inside a polygon defined by @poly?
>> sub in_poly
>> {
>> 	my ( $x, $y, @poly ) = @_;
>> 	my $c = 0;
>> 	my @ladder = slice ( $x, @poly );
>> 
>> 	while (@ladder)
>> 	{
>> 		my $rung = shift @ladder;
>> 
>> 		# special case: we're on the edge
>> 		if ( $y == $rung ) {
>> 			# trailing edge
>> 			$c++ unless $c % 2;
>> 		}
>> 		# we know we're on-edge/encompassed-by the polygon
>> 		last if ( $y <= $rung );
>> 
>> 		# odd is in, even is out (promote diversity!)
>> 		$c++;
>> 	}
>> 	return ($c % 2) ? "hit!" : "miss!";
>> }
>
>###
># is a point x,y inside a polygon defined by @poly?
>sub in_poly
>{
>	my ( $x, $y, @poly ) = @_;
>	my $c = 0;
>
>	my @ladder = slice ( $x, @poly );
>
>	while ( (my $rung) = shift @ladder )
>	{
>		last if ( $y <= $rung && ($c%2) );
>		$c++;
>	}
>	return ($c % 2) ? "hit!" : "miss!";
>}
>
>Hmm, would I have to pay my employer for a negative line count in my
>productivity assessment?  Maybe I shoulda got it right the first time...
>
>Where can I get one of those buzzers Larry Wall was using to keep him
>on a given topic for a limited time?
>
>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.




More information about the San-Diego-pm mailing list