473,548 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

If a given point in the plane lies inside, outside, or on the boundary of a polygon ?

1 New Member
Hello friend.
I want to write a program whether a given point in the plane lies inside, outside, or on the boundary of a polygon. I have found this interesting website which shows 2 ways of doing that. i.e InsidePolygon() and pnpoly()

http://local.wasp.uwa.edu.au/~pbourk...ry/insidepoly/

But these Algo/code don't detect if the input pt is on the boundary of a polygon?

Can you guys help me in that part of code/algo?

Your help is much appreciated.

~ Jenny
Sep 15 '10 #1
1 2478
newb16
687 Contributor
It requires to check is F(x,y)==0 for F describing a segment of the polygon, but as floating point calculations are imprecise, you will have to determine what precision is required and check abs(F(x,y)) < e instead.
it seems that relevand portion is
if (p1.x == p2.x || p.x <= xinters)
and you could use if (fabs(p.x-xinters)<epsilo n) but this will not work on nearly horizontal segments.
Sep 15 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1345
by: A-PK | last post by:
Hi, How could I set the presence of the form to be called to be locked inside the boundary of the calling form ? I got A and B form A form contain tree view menu and B form was part of the tree view menu item. So when I click the tree view menu item and select B form to be showed under A form.
8
2559
by: Piotre Ugrumov | last post by:
How can I implement a function that calculate the coordinates of a point, in 3 dimensional space? The function take 6 value (x, y, z, v(velocity), corner alfa, corner beta). The prototype is this: double coordinate(double x, double y, double z, double c, double alfa, double beta); How can I implement a function that return the corner...
6
3636
BSOB
by: BSOB | last post by:
im gone for a long weekend so plenty of time for anyone to answer. if i have 4 points representing a polygon and each point is represented by an x and a y coordinate, is there an easy (or slightly less painfull) way to decide whether or not a point (a,b) lays within that polygon? please note that this polygon DOES NOT take the shape of a...
4
4074
by: tbrown | last post by:
I have a listbox on my form and I set it to invisible. When a particular button on the form is pressed, I make the listbox visible and allow the user to select from it. When the selection occurs, the listbox is made invisible again. What I want to do is automatically make the listbox invisible if it is visible and the user clicks the...
1
8405
by: renu | last post by:
Hello, I have drawn polygon on window. And I want to check wheather given point is in that polygon region or not? How shold I find that? I have created object of class region GraphicsPath path = new GraphicsPath(); path.AddPolygon(pts); //////// Some points I have passed Region rgn = new Region(path); RegionData rgnDta =...
4
11642
by: Uffe | last post by:
Is it possible to play a Flash Vide file (FLV) inside an VB.net application. (Example http://www.eurovision.tv/addons/mediaplayer/video/fin.flv ) I have succesfully done similar VB.net applications before, like playing SWF files, by using the com componet Shockwave Flash Object from Adobe. I thought that it would work for FLV files too, but...
8
7499
by: SM | last post by:
I've always wonder if there is diference when declaring and initializing a varible inside/outside a loop. What's a better practice? Declaring and initializing variables inside a loop routine, like this: for(var i=0; i<list; i++) { var name = list; }
10
9156
by: itrose | last post by:
Hi, Can anyone tell me how to recognize geometric shape using C#? I have geometric shapes like triangle, hexagon, pentagon, diamond, square,parallelogram, rectangle, etc. I have drawn all these shapes using mspaint. i have one picture box, using opendialog i am selecting any of the geometric shapes, into picturebox. I want to identify...
0
7711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7954
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7805
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6039
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5367
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3478
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1054
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
755
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.