Re: Check of point inside/outside polygon

2017-01-11 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 13:32:00 UTC, Suliman wrote: Ideally I need algorithm that can return bool if one polygon overlapped/intersected by another. But I do not know math. After some googling I found topic on SO[1] about point inside/outside polygon. It's not directly what I need, but as

Re: Check of point inside/outside polygon

2016-07-27 Thread CRAIG DILLABAUGH via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 14:56:13 UTC, Suliman wrote: On Wednesday, 27 July 2016 at 12:47:14 UTC, chmike wrote: On Wednesday, 27 July 2016 at 09:39:18 UTC, Suliman wrote: clip Sorry, its my issue I am thinging about polygons, but for me would be enought points. The problem is next. I

Re: Check of point inside/outside polygon

2016-07-27 Thread Suliman via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 12:47:14 UTC, chmike wrote: On Wednesday, 27 July 2016 at 09:39:18 UTC, Suliman wrote: ... Big thanks! Ehm... Now I should add iteration on array of points in first and second polygon? If it's not hard for you could you show how it should look please. Sorry, I

Re: Check of point inside/outside polygon

2016-07-27 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 09:39:18 UTC, Suliman wrote: On Wednesday, 27 July 2016 at 08:40:15 UTC, chmike wrote: The algorithm is to draw a horizontal (or vertical) half line starting at your point and count the number of polygon edges crossed by the line. If that number is even, the point

Re: Check of point inside/outside polygon

2016-07-27 Thread chmike via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 09:39:18 UTC, Suliman wrote: ... Big thanks! Ehm... Now I should add iteration on array of points in first and second polygon? If it's not hard for you could you show how it should look please. Sorry, I may have misunderstood the initial problem. You were

Re: Check of point inside/outside polygon

2016-07-27 Thread Suliman via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 08:40:15 UTC, chmike wrote: The algorithm is to draw a horizontal (or vertical) half line starting at your point and count the number of polygon edges crossed by the line. If that number is even, the point is outside the polygon, if it's odd, the point is inside.

Re: Check of point inside/outside polygon

2016-07-27 Thread chmike via Digitalmars-d-learn
The algorithm is to draw a horizontal (or vertical) half line starting at your point and count the number of polygon edges crossed by the line. If that number is even, the point is outside the polygon, if it's odd, the point is inside. Let (x,y) be the point to test and (x1,y1)(x2,y2) the end

Re: Check of point inside/outside polygon

2016-07-26 Thread Gorge Jingale via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 19:08:09 UTC, H. S. Teoh wrote: On Tue, Jul 26, 2016 at 06:39:58PM +, Gorge Jingale via Digitalmars-d-learn wrote: On Tuesday, 26 July 2016 at 17:38:43 UTC, Suliman wrote: > I have arbitrary polygon. I need any solution. Performance > is does not matter at

Re: Check of point inside/outside polygon

2016-07-26 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 26, 2016 at 06:39:58PM +, Gorge Jingale via Digitalmars-d-learn wrote: > On Tuesday, 26 July 2016 at 17:38:43 UTC, Suliman wrote: > > I have arbitrary polygon. I need any solution. Performance is does not > > matter at current moment. > > A polygon is made up of lines. For a

Re: Check of point inside/outside polygon

2016-07-26 Thread Gorge Jingale via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 17:38:43 UTC, Suliman wrote: I have arbitrary polygon. I need any solution. Performance is does not matter at current moment. A polygon is made up of lines. For a point to be inside a convex polygon, it must be to the "right" of all the lines with clockwise

Re: Check of point inside/outside polygon

2016-07-26 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 26, 2016 at 05:38:43PM +, Suliman via Digitalmars-d-learn wrote: > I have arbitrary polygon. I need any solution. Performance is does not > matter at current moment. In that case, maybe you'd want to look at: https://en.wikipedia.org/wiki/Vatti_clipping_algorithm Note,

Re: Check of point inside/outside polygon

2016-07-26 Thread Suliman via Digitalmars-d-learn
I have arbitrary polygon. I need any solution. Performance is does not matter at current moment.

Re: Check of point inside/outside polygon

2016-07-26 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 26, 2016 at 01:32:00PM +, Suliman via Digitalmars-d-learn wrote: > Ideally I need algorithm that can return bool if one polygon > overlapped/intersected by another. But I do not know math. Are you talking about triangles, or general polygons? Are the polygons convex or arbitrary?

Check of point inside/outside polygon

2016-07-26 Thread Suliman via Digitalmars-d-learn
Ideally I need algorithm that can return bool if one polygon overlapped/intersected by another. But I do not know math. After some googling I found topic on SO[1] about point inside/outside polygon. It's not directly what I need, but as temporal solution would be enough. Maybe somebody