Results 1 to 2 of 2

Math Help - 2D collision between a moving circle and a fixed line segment

  1. #1
    Newbie
    Joined
    Aug 2011
    Posts
    1

    Question 2D collision between a moving circle and a fixed line segment

    In the context of a game program, I have a moving circle and a fixed line segment. The segment can have an arbitrary size and orientation.
    • I know the radius of the circle: r
    • I know the coordinates of the circle before the move: (xC1, yC1)
    • I know the coordinates of the circle after the move: (xC2, yC2)
    • I know the coordinates of the extremities of the line segment: (xL1, yL1) - (xL2, yL2)


    I am having difficulties trying to compute:
    • A boolean: If any part of the circle hits the line segment while moving from (xC1, yC1) to (xC2, yC2)
    • If the boolean is true, the coordinates (x, y) of the center of the circle when it hits the line segment (I mean when circle is tangent to segment for the first time)
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    earboth's Avatar
    Joined
    Jan 2006
    From
    Germany
    Posts
    5,829
    Thanks
    123

    Re: 2D collision between a moving circle and a fixed line segment

    Quote Originally Posted by joeljoel View Post
    In the context of a game program, I have a moving circle and a fixed line segment. The segment can have an arbitrary size and orientation.
    [LIST][*]I know the radius of the circle: r[*]I know the coordinates of the circle before the move: (xC1, yC1)[*]I know the coordinates of the circle after the move: (xC2, yC2)[*]I know the coordinates of the extremities of the line segment: (xL1, yL1) - (xL2, yL2)

    I am having difficulties trying to compute:
    • A boolean: If any part of the circle hits the line segment while moving from (xC1, yC1) to (xC2, yC2)
    • If the boolean is true, the coordinates (x, y) of the center of the circle when it hits the line segment (I mean when circle is tangent to segment for the first time)
    Here is how I would do this question:

    1. Determine the equation of the line-segment:

    \dfrac{y-yL1}{x-xL1} = \dfrac{yL2-yL1}{xL2-xL1}

    Re-write this equation into the form

    Ax + By + C =0

    2. If the circle touches the line the center of the circle has the distance r from the line. The distance of a point P(p, q) from the line is calculated by:

    d = \dfrac{Ap+Bq - C}{\sqrt{A^2+B^2}}

    (You see here why it is essential that you transform the equation of the line)

    3. Obviously the center of the circle is moving on straight line too such that the y-coordinate of the center is a constant. Set d = r and solve for the x-coordinate of the new center.

    4. You'll get 2 different circles which satisfy the given conditions.
    Attached Thumbnails Attached Thumbnails 2D collision between a moving circle and a fixed line segment-movcircle.png  
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: June 1st 2011, 06:10 AM
  2. Replies: 1
    Last Post: February 21st 2011, 10:54 PM
  3. moving on circumference of circle
    Posted in the Geometry Forum
    Replies: 4
    Last Post: March 30th 2009, 07:24 AM
  4. Segment of a Circle
    Posted in the Geometry Forum
    Replies: 2
    Last Post: January 9th 2009, 08:04 AM
  5. The segment of a circle
    Posted in the Geometry Forum
    Replies: 2
    Last Post: August 31st 2007, 10:53 AM

Search Tags


/mathhelpforum @mathhelpforum