Get Rays From Point To Polygon

Consider the follow example:

const polygon = new Phaser.Geom.Polygon([0,0, 100,0, 50,90])
const n_inters = Phaser.Geom.Intersects.GetRaysFromPointToPolygon(200, 200, polygon)

Why am I getting 6 vectors/intersections? the point(200, 200) should return 0 intersections

Version: 3.54.0 Windows Chrome

That method description doesn’t quite make sense to me, because it seems you will always get some intersections. It casts 3 rays per vertex and keeps the intersecting ones.

You may want Polygon.Contains() instead.

1 Like