Results 1 to 3 of 3

Thread: Sphere-sphere collision detection

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002

    Sphere-sphere collision detection

    I am having so much trouble working out how to do sphere-sphere collision detection. I've done lots of research but they all seem to concentrate on the situation of a sphere passing through another sphere (thus seemingly no collision) rather than detecting if one sphere touches another one (which I need as a starting point and can build upon myself). They say it's easy but I can't figure it out (I don't know much about dot and cross product). Could someone give me a brief description on how to detect sphere-sphere collisions?

  2. #2

    Re: Sphere-sphere collision detection

    I've never implemented one or anything, but i have a really basic understanding of it. In a sphere, the radius is constant right? So say you have two spheres floating around. If the distance between the two spheres is less than the sum of radius one and radius two, then you ahve collision.

    For example say you have a bullet heading towards a person. The person's sphere has a radius of 4 units and the bullet has a radius of 2 units (yeah it's a big bullet). So it looks like this
    Code :
      2    2              4 units    4 units
    |----|----|      |--------|--------|
       bullet              person
    If the distance from the center of the the bullet sphere to the center of the person sphere was less than or equal to 6, then we have a collision. There are 2 2's and 4's because that is the length of the radius and i'm showing the diameter. I hope this makes sense. If you don't get something about it, just say so and i'll elaborate or clear it up.

    - Halcyon

    Edit: Sorry the picture was kinda misaligned.

    [This message has been edited by Halcyon (edited 01-08-2003).]

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jul 2001

    Re: Sphere-sphere collision detection

    Yeah, that's it. Here are the formulas :

    Assume the spheres are named A and B.
    Denote by rA and rB their radii, and by (xA, yA, zA) and (xB, yB, zB) the coords of their centers.

    Then :
    The spheres intersect each other if and only if
    (xA-xB)+(yA-yB)+(zA-zB) < (rA+rB)
    The spheres are tangent to each other if and only if
    (xA-xB)+(yA-yB)+(zA-zB) = (rA+rB)

Similar Threads

  1. Sliding box / sphere collision
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-17-2005, 02:04 PM
  2. BSP Trees and sphere collision detection/response
    By LostInTheWoods in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 12-26-2003, 10:11 AM
  3. Rotating cube, sphere and collision.
    By UnIcron in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-24-2003, 12:02 AM
  4. sphere and plane collision
    By UnIcron in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-20-2003, 04:12 AM
  5. Collision, sphere moving down a slope?
    By detzel in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 01-22-2002, 09:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean