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
- Favorites in PackageManager
- LudumDare59 : Signal
- Unity Editor: Tree Generator
- Leaf/Foliage Generator Tools (Runs in Browser)
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
Recent Comments
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by











