Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Collision detection with lines&circles


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Floru   Members   -  Reputation: 124

Like
Likes
Like

Posted 11 August 2001 - 01:48 AM

Hi! I''m not very good at maths but I think that the best solution to my problem is using vector math. I want to make a very good (or perfect) collision detection function which detects if lines/circles are colliding. There would be 3 functions: BOOL LinesColliding(line1 coordinates, line2 coordinates) BOOL CirclesColliding(circle1 pos and rad, circle2 pos and rad) BOOL LineAndCircleColliding(line coordinates, circle pos and rad) Checking circles together is easy because you just have to check the distance between them. But I don''t know how to do it with lines. Could someone please help? Thanks Floru

Sponsor:

#2 LilBudyWizer   Members   -  Reputation: 491

Like
Likes
Like

Posted 11 August 2001 - 12:58 PM

If you calculate the distance from a point on a line to the center of the circle that gives you the hypotenuse of a right triangle. The dot product of a vector from that point to the center of the circle with a unit vector pointed down the line gives you a projection of that vector onto the line, i.e. a second side. You need the third side, but I''ll assume that given the length of two sides of a right triangle that you can find the third. If that third side is less than the radius then the point of intersection can be found from the the third side and the radius of the circle. Those are two side of another right triangle with the radius of the circle the hypotenuse. The third side of that right triangle is the distance along the line to the two points of intersection with the circle.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS