Object in line of sight (2D)

Blitz3D Forums/Blitz3D Beginners Area/Object in line of sight (2D)

gingerprince(Posted 2007) [#1]
I have a line X1,Y1 to X2,Y2.

I have an object at OBX,OBY with radius OBR (circle in this case)

I`m looking for code/algorithm that will tell me if the `Object` overlaps the line (ie In the line of sight)

Many thanks


jfk EO-11110(Posted 2007) [#2]
You mean if the line crosses the circle (based on OBR) somewhere?
I think I remember there was a line intersect circle example in the code archies, no?

From elias_t is this ray shpere intersection, I think you could mod it to work with a circle:
http://www.blitzbasic.com/codearcs/codearcs.php?code=947

You may also optimize it, if one of the point is already within the radius, then skip the pytagoras thingie.


gingerprince(Posted 2007) [#3]
cheers