Results 1 to 5 of 5

Math Help - Distance from circle to rectangle's corner (from outside)

  1. #1
    Newbie
    Joined
    Nov 2007
    Posts
    3

    Distance from circle to rectangle's corner (from outside)

    Hello!

    Does anyone know how to calculate the distance between a circle and a corner of a rectangle as I have illustrated in this animation.

    Thanks!

    René Vaessen.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Opalg's Avatar
    Joined
    Aug 2007
    From
    Leeds, UK
    Posts
    4,041
    Thanks
    7
    Quote Originally Posted by Rene_vaessen View Post
    Hello!

    Does anyone know how to calculate the distance between a circle and a corner of a rectangle as I have illustrated in this animation.
    Nice animation!

    The answer to the question is easy (assuming you know the position of the point p2). The points p1, p2 and m (at time of collision) form a right-angled triangle whose hypotenuse is the radius of the circle. So you can find the distance from p2 to m by Pythagoras' theorem.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Nov 2007
    Posts
    3

    Not really what i'm looking for

    ..then I have the distance between p2 and m, but I don't know the distance between unknown point m2 (which I called m@collisiontime) and point p2. That's the tricky one.

    I thought later, there is more wronge, because p1 is the corner in this situation, but it is calculated as by getting the closestpoint on the rectangle to the center of the circle. This could be wronge because the circle's movement path could bring the circle very close to a corner it's never going to hit.

    So I know how to do it now, IF i find a nice way of calculating the corner he is going to hit, Hence how do I now it's even going to hit a corner..

    I'm in trouble! :-)
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor
    Opalg's Avatar
    Joined
    Aug 2007
    From
    Leeds, UK
    Posts
    4,041
    Thanks
    7
    Quote Originally Posted by Rene_vaessen View Post
    ..then I have the distance between p2 and m, but I don't know the distance between unknown point m2 (which I called m@collisiontime) and point p2. That's the tricky one.
    No! The distance d(m2,p2) between m2 and p2 is exactly what Pythagoras tells you. I'm assuming that you know the location of p2 (because it is the point where the line L1 meets the line along which m moves). So you know the distance d(p1,p2) from p1 to p2. You also know the distance d(m2,p1), because that is the radius of the circle (it is the distance from the centre of the circle to the point on the circumference where the impact takes place). Pythagoras says that d(m_2,p_2) = \sqrt{d(m_2,p_1)^2 - d(p_1,p_2)^2}.

    Quote Originally Posted by Rene_vaessen View Post
    how do I now it's even going to hit a corner..
    Look at it this way. If the circle hits the edge of the rectangle (not the corner), then at the moment of impact the vertical distance from the centre of the circle to the edge of the rectangle will be equal to the radius of the circle, and the point of impact will be vertically above m2 (the centre of the circle at the moment of impact). So the condition for the circle to hit the corner p1 of the rectangle is that the vertical distance from p1 to the line along which m moves must be less than the radius of the circle. That will ensure that the circle hits the corner before it has travelled far enough to bounce off the edge.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Nov 2007
    Posts
    3

    Re: I agree for 100% :-)

    Hi again,

    First I like to thank you for your help, because it gives me new perspective, something I was really looking for.

    Don't ask me why I missed that that I could calculate it so easily, but my head was all messed up.. :-)

    That's why I made the animation, to relax a little..

    >the point of impact will be vertically above m2 (the centre of the circle at the moment of impact).

    Did you mean below? or maybe the left edge of the rectangle?

    I don't quit get you method of detecting if a collision will occur to a corner..

    PS: Bare in mind that the angle of the circle's ray can be any angle, and the circle's position can be in any orientation to the rectangle)

    But what I have come up with now is that I calculate the distance between point a and m2 just as like I would do if I knew it would hit an edge for sure.

    And then calculate m2 with that, and see if the the tangent point of the circle (in direction towards the impactpoint) is in or outside the rectangle. If it is outside we have hit a corner. I hope it's right though. :-)
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 3
    Last Post: July 2nd 2011, 08:03 PM
  2. Construction Rectangle in Circle
    Posted in the Geometry Forum
    Replies: 7
    Last Post: February 14th 2011, 05:13 PM
  3. [SOLVED] Radius of a rounded corner rectangle
    Posted in the Geometry Forum
    Replies: 7
    Last Post: March 1st 2010, 06:53 PM
  4. Help rectangle in circle
    Posted in the Geometry Forum
    Replies: 3
    Last Post: January 29th 2010, 07:06 PM
  5. rectangle inscribed in a circle
    Posted in the Geometry Forum
    Replies: 1
    Last Post: November 7th 2009, 08:27 AM

Search Tags


/mathhelpforum @mathhelpforum