Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

How can you determine when a moving sphere intersects a line segment, and the normal of that intersection?

Ideally Javascript, but anything that's tidy, simple and self-contained and easy to port to Javascript.

Here's a very nice video of the problem I'm trying to solve: http://www.youtube.com/watch?v=V7ebhHcF_ys

share|improve this question
    
I know you've already looked at this, while the link is dead, the steps shown are clear enough. Additionally, you can look at swept AABB code here. –  Byte56 Dec 14 '12 at 18:24
    
@Byte56 yes, but I don't understand it. The steps are not clear enough to me. I'm a consumer of geometry code and not a gifted creator of it. I mostly want to focus this Ludum Dare on things that interest me e.g. simulation of economy and so want a quick trusty ready-coded collision function to use. And I'm so surprised they aren't everywhere. I had a similar problem trying to work out how to do ball to triangle 3D too :( –  Will Dec 14 '12 at 18:29
    
Keep in mind that a moving sphere is just a capsule. Or, alternatively, two spheres and a cylinder (rectangle in 2D). If you can do those basic intersection tests, you can easily code a swept-sphere to line test. –  Sean Middleditch Dec 14 '12 at 18:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.