views:

113

answers:

3

Dear all,

Is it possible to find out whether one drawing line (which is not in a horizontal or vertical position) overlapped (or touched) any other items (like line, rectangle, circle etc). Kindly advise me on the possibilities and solution with examples.

Thanks for looking into this...

+5  A: 

Sure it's possible. Check out Collision Detection. Some libraries and languages have certain features which makes this easier than others. You'll need to give more details regarding your application for more specific assistance.

Jonathan Sampson
A: 

For this, you need to compute the intersection/collision with your line and the other lines, rectangle, circles, etc...

For the intersection of two lines, you need to compute the intersection coordinates and check if they are in the boundaries of your scene.

For the intersection of the line and a circle, you need to compute the distance between the line and the center of the circle: if this distance if greater than the radius, there is no intersection.

ThibThib
+1  A: 

Check Google for the Separating Axis Theorem. It's used in Collision Detection widely as it works for almost any polygon/object

Scoregraphic