Sign in to follow this  
lightfoot256

Line of Sight interception with a circle

Recommended Posts

lightfoot256    122
Heya, I'm working on a line-of-sight algorithm that sends out rays from its current position into the world returning a list of the objects that it can see and the distance of the objects from the initial starting point. For now, all the objects will use circles as their collision shape... I've managed to get it to check if an object exists on a given line, but am a little stumped to how to find out how far away that object is... i.e. how far from the point to the exact point on the circle that it colided with. Any help would be much appreciated, thanks! Chris

Share this post


Link to post
Share on other sites
oliii    2196
the raytrace should give you a 't' value. that is the disatnce from the start point to the intersection on the circle.

Else a good approximation would be the projected distance of the centre of te circle to the ray, or just the distance of the ray centre to teh start position. That should be accurate enough over long distances (circle radius being small).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this