15
2024
Check if point is inside polygon 2D (using line intersection)

Info:
“Each time the ray crossed the boundary of the polygon, it would cross from the interior to the exterior, or vice versa. Therefore, the test point is on the interior if, and only if, the ray crosses the boundary an odd number of times“
https://www.topcoder.com/thrive/articles/Geometry%20Concepts%20part%203:%20Using%20Geometry%20in%20Topcoder%20ProblemsTested the algorithm above and seems to work! : o
Source:
https://gist.github.com/unitycoder/e769e6e7f4d0ee50f983d1265e6f15d9Line Intersection method:
https://forum.unity.com/threads/line-intersection.17384/#post-4442284Note: Unity has build-in method already,
https://docs.unity3d.com/ScriptReference/Collider2D.OverlapPoint.htmlVideo: (making of)
Related Posts
Leave a comment
Recent posts
- Editor Tool: Scene Size Analyzer
- LudumDare 60: Old Tech
- uBasic Scripting Language for Unity
- GreaseMonkey+Editor Plugin: 1-Click Copy script from ChatGPT (Web) to Unity Editor (as script)
- Editor Tool: Property Watcher
- .unityignore : Hide files from Project window
- PostBuild Script to Create Single exe Standalone File
- Game Loop Designer
- Favorites in PackageManager
- LudumDare59 : Signal
- Unity Editor: Tree Generator
- Leaf/Foliage Generator Tools (Runs in Browser)
Recent Comments
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by











