Results 1 to 13 of 13

Thread: [resolved] Oval collision detection - how to?

Threaded View

  1. #5
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Oval collision detection - how to?

    Well, I'm going to assume you work with ellipses all of the same size and the same orientation as you've mentioned they are not rotated (this latter assumption considerably simplifies the problem).

    Let's consider a pair of ellipses. I'll set the coordinate origin at the center of one of them (see figure).

    A collision will take place if

    F = OO' - (OM + ON) <=0

    By symmetry, OM = ON so:

    F = OO' - 2*OM <=0

    In order to find OM we need the intercept of the first ellipse with the line connecting the centers, i.e. we must solve this system of equations:

    (x/a)2 + (y/b)2 = 1
    y = (q/p)x

    where a and b are the semiaxes and (p,q) are the coordinates of the center for the second ellipse. This leads to:

    (x/a)2 + ((qx/p)/b)2 = 1

    and finally:

    x = abp/Sqrt(a2q2 + b2p2)
    y = abq/Sqrt(a2q2 + b2p2)

    so that OM = Sqrt(x2 + y2) = ab*Sqrt(p2 + q2) / Sqrt(a2q2 + b2p2)

    The distance OO' is:

    OO' = Sqrt(p2 + q2)

    Therefore the condition for collision becomes:

    0 >= F = Sqrt(p2 + q2) - 2ab*Sqrt(p2 + q2) / Sqrt(a2q2 + b2p2) =
    Sqrt(p2 + q2) * [1 - 2ab / Sqrt(a2q2 + b2p2)]

    Because Sqrt(p2 + q2) is positive, then:

    1 - 2ab / Sqrt(a2q2 + b2p2) <= 0

    which can be finally expressed more ellegantly as:

    Sqrt[(p / a)2 + (q / b)2] <= 2
    Attached Images Attached Images  
    Last edited by krtxmrtz; Nov 7th, 2005 at 03:55 AM.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width