Skip to main content
GameDev.net gamedev.net
🔒 Locked

Poly / Line intersection

Started by Sharky-X Apr 10, 2001 at 10:23 AM 0 replies 400+ views
Original Post
Sharky-X
Sharky-X
Hey there, I need a fast algorithm which detects if a line intersects with a poly ( both are in 2D ) for my collision detection. Thanks in advance Jörg Rüppel
Diodor
Diodor
There are easy algorithms for intersecting a line with a convex poly. If you have concave (forgive spelling) polies, you can try dividing those in convex polies and intersecting with the convex polies.


If most of the time the line and the poly dont intersect, you can speed up the algorithms a lot by precalculating for each poly the center and the radius of a circle that encompasses all of the polies points. Then, you calculate the distance from the circle center (a 2d point) to your line (very fast). If this distance is greater than the circle radius, the poly doesnt intersect the line and you can skip to the next poly.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.