Reputation: 24757
I have a 3D world with curves. Each curve is simply a list of 3D points. When user clicks on the scree, i would like to test if the point is in a closed area. For example, the user draws four curves that form a rectangle. If he clicks inside this rectangle i would like to "know" that it is a closed area.
I could not find any known algorithms - how i can achieve this behaviour?
Upvotes: 0
Views: 55
Reputation: 41523
Assuming your "closed areas" are all planar: For each area, find the point of intersection between the pick-ray and the area's plane. Then use an odd-even crossing test (following a ray in that plane) to determine whether the point is inside that area.
If your areas are not planar, you can instead use a winding test, where you sum the signed angles about the pick-ray of each consecutive pair of points in the area, and see whether that sum is nonzero (accounting for numerical drift).
Upvotes: 1