1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Calculate point in ellipse given a unit vector

  1. Jun 30, 2011 #1
    Hi to everyone.

    I'm detecting collision between two ellipses. I've got my unit vector, my ellipse center and radius (horizontal and vertical). I want to calculate the point that lies in the ellipse on the direction of the unit vector. See the image attached. Suppose the red arrow is my unit vector and I want to get the coordinates of the green colored point. I'm just multiplying my unit vector times my radius plus the center of the ellipse. The formula looks like this:

    Code (Text):


    //Assume unit vector has been already calculated at this stage, ellipseCenter and ellipseRadius has been given
    Vector pointInEllipse = VectorMake(unitVector.x * ellipseRadius.x + ellipseCenter.x, unitVector.y * ellipseRadius.y + ellipseCenter.y);

     
    The point I get using the above formula lies on the ellipse, but it's translated on both axis a little bit, translated enough to detect collisions when haven't occurred any.
    What am I missing here?

    Thank you very much in advance.
     

    Attached Files:

  2. jcsd
  3. Jun 30, 2011 #2

    LCKurtz

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    I've never heard of an ellipse radius. If the equation of the ellipse is

    [tex]\frac{x^2}{a^2}+\frac{y^2}{b^2}=1[/tex]

    what quantity represents the "ellipse radius"?
     
  4. Jun 30, 2011 #3
    I apologize for that, it's a and b from that equation, ellipseRadius.x = a and ellipseRadius.y = b.
     
  5. Jun 30, 2011 #4

    LCKurtz

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    I have trouble deciphering your syntax in that programming language. But if you have a unit vector you have the slope m. Assuming the picture is translated to the origin, why not just solve y = mx with the equation of the ellipse? A quick calculation seems to show you just need to calculate something like

    [tex]x=\pm\frac{ab}{\sqrt{m^2+b^2}}[/tex]
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook