I am writing a code that requires finding if a point is inside a specific geometry. The geometry may an n sided polygon (not necessarily convex) in 2 Dimensions or an STL geometry in 3 dimensions. I can actually write a search code using some algorithms available. But I am looking for a software library that can serve such purposes. It can be part of a bigger library. Any suggestion towards any such libraries or codes freely available would do. Thank You.
In any case, for any convex polygon (including rectangle) the test is very simple: check each edge of the polygon, assuming each edge is oriented in counterclockwise direction, and test whether the point lies to the left of the edge (in the left-hand half-plane). If all edges pass the test - the point is inside.
Transform the point with the inverse transform of the box, then the check becomes one against an axis aligned box. Alternatively do a check against each side of the box. If the point is to the left of all 4 sides (sides considered clockwise, head to tail) the point is inside the box.
Use polygon. contains(point) to test if point is inside ( True ) or outside ( False ) the polygon.
The simplest way to determine if a point lies inside a triangle is to check the number of points in the convex hull of the vertices of the triangle adjoined with the point in question. If the hull has three points, the point lies in the triangle's interior; if it is four, it lies outside the triangle.
How about Wykobi
Wykobi is an extremly efficient, robust and simple to use C++ 2D/3D oriented computational geometry library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With