new method to judge if a point is inside of a polygon

preview_player
Показать описание
This is a method to judge if a point is inside of a polygon or not.
It surely works but I do not know how to prove it.

Also, I believe this method works for higher dimension. For example in 3D, you want to judge if point P is inside of a polyhedron made from triangle faces. You then choose a point A on the polyhedron, and iterate all other triangle faces which does not include A, and count how many tetrahedrons made by these face and A contains point P. If the number is odd then the point is inside of the 3D shape.
If you goes to 4D, then choose point A and iterate all tetrahedron, then construct "5-cell" for each tetrahedron with A, then count how many "5-cell"s does P belong to.

The program in the last part of my video is here:

* This method is called "triangle fan" and it is discovered earlier. You can find more information in:
Рекомендации по теме
Комментарии
Автор

I think there is a problem in this logic, if a point is located on a line of imaginary triangle, it will be counted twice and the result will be out while the point is actually in

mostafasamy
Автор

Supposedly at the figure of 3:47, if the geometry was such as ADC aligns on a straight line, you wouldn't have a triangle then.

jonathanhandojo
Автор

An easier way is to just raycast from the point to another point outside the polygon, and count the number of intersections with the edges of the polygon. An odd number of intersections is inside, and even is outside.

kplays_
Автор

Hi Xiaoyou Zhai
I liked your method for finding the point inside the triangle. But I think when the point is on edge of triangle your algorithm may give wrong result. Need to improve on this.

kdipakj
Автор

Does not seem to work for the following case: Point(185, 124), Point(383, 62), Point(433, 231), Point(259, 254), Point(285, 36), Point(403, 301)

unknownuser
Автор

I have used your method for work that will be published. How do I give you credit? Have you published this somewhere?

mjnp
Автор

Hi ! I really like your method but unfortunately it doesn't work if the polygon is overlapping itself.
Try with those points: [[222, 236], [482, 226], [474, 344], [275, 186], [465, 185], [326, 302]]

titouant
Автор

omg thank you so much for that great method !!!

randomaccount