# Math Help - Solving when a circle and rotating line collide

1. ## Solving when a circle and rotating line collide

I am trying to solve for when a circle and a line rotating about a point will collide:
Updated:

I am trying to solve for T.

The arrow from Bo to B represents Bv or the velocity of the circle.
The arrow from the bottom line to P represents θv or the change of the rotating line.
The dashed line and circle represents a possible solution to the problem and I only put it there to help me think through the problem.

Constants:
L: length of the rotating line (CP)
C: point the line rotates around
Cx, Cy: components of C
Bo: initial point/location of the circle
Box, Boy: components of Bo
Bv: velocity of the circle
Bvx, Bvy: components of Bv
θ: initial rotation of the rotating line (CP)
θv: rotational velocity of the rotating line (CP)

Variables:
P: end point of the rotating line (CP) at time T
Px, Py: components of P
N: normal of the line rotating line (CP) at time T
Nx, Ny: components of N
B: point/location of the circle at time T
Bx, By: components of B
D: distance from the center of the circle (B) to the rotating line (CP) at time T
T: time (from 0 to 1)

In the last equation t is confusing and a bad choice for a variable. It simply represents θ + θv * T as stated.

Here is my reasoning:
At the top I have the positions of the endpoint of the rotating line P and the center of the circle B defined as functions of time T. In order to determine the position of the collision, I must find at what time T the distance D from the center of the circle B and the line CP is equal to the radius of the circle r, or D - r = 0. The distance from a point to a line can be found by taking the dot product of the normal of the line (N) and the point (B). Knowing this I simply expand the equation until all the variables are present and I am left with the final equation at the bottom. I re-condensed the equation into terms of a, b, and t hoping it would help me solve the problem. If I can get t out of the sine and cosine functions, I would be able to solve the problem.

I can't figure out what to do from here. I have been staring at this for days.

Thanks,
- Mike

2. I guess I'm not the only one who can't solve this. Do I need to include additional information?

3. Hmm. Lack of patience on the part of someone requesting help does not imply lack of competence on the part of someone who might help.

You have an extremely confusing drawing with a multitude of variables.

1. In looking at your post, I don't know what points are fixed, and what points are rotating about what.
2. You want to know when which circle will collide with which rotating line?
3. Are these rotations at a constant angular velocity?
4. What is that velocity?
5. What is T?
6. What is t?

Specify a coordinate system if it's part of the original problem statement. Please provide a complete listing of all your variables, and what they mean. Include units if appropriate.

Cheers.

4. My apologies. This problem is for a computer science project that is due shortly, hense my impacients. I was atempting a comical bump and was not trying to bring into question the competence of the people of this forum. This is my first time posting on a math forums so I apologize for the lack of necessary information.

Thanks for bringing this to my attention. Updated the first post.

5. Apology accepted.

A few more questions:

1. What constants and variables are known?
2. Are the two velocities (linear velocity of the circle, and angular velocity of the line) constant?

It seems to me that the relative sizes of these two velocities are going to be critical. For certain values of those velocities, there will be no collision. Preferably, any solution would provide conditions the two velocities would have to satisfy in order for there to be a collision.

6. All constants and variables are known except T, and P and B as they are a function of T. It is simply a matter of solving for T.

Both velocities are constant.

You are correct to say that there may be no collision at all. In such cases I am assuming that the equation will return invalid or impossible answers which will be checked by the program.

I have been trying to think of alternate ways to find P at time T without using the trig functions, but I have found nothing.

Edit:
Just noticed a flaw in my math. The endpoint of the line P must be multiplied by the length L.

1. I would probably draw the angle $\theta$ going from the postive x axis to the initial rotation of the vector CP. That is the usual method.

2. I'm not sure if I agree with your expression for the normal vector $\hat{N}.$ You're rotating in the clockwise direction, correct? That corresponds to a negative angle. That is, the rotation matrix associated with the rotation $-\pi/2$ is given by

$R_{-\pi/2}=\begin{bmatrix}\cos(-\pi/2) &-\sin(-\pi/2)\\ \sin(-\pi/2) &\cos(-\pi/2)\end{bmatrix}=\begin{bmatrix}0 &1\\-1&0\end{bmatrix},$

and you're defining (if I have it correct)

$\displaystyle\hat{N}=\frac{R_{-\pi/2}\vec{CP}}{L}.$

In that case, I get

$\hat{N}=\dfrac{1}{L}\langle P_{y}-C_{y},C_{x}-P_{x}\rangle.$

If you carry this correction through, I get

$(B_{0x}+B_{vx}T)\sin(\theta+\theta_{v}T)-(B_{0y}+B_{vy}T)\cos(\theta+\theta_{v}T)=r.$

This is a transcendental equation for $T.$ There is no known analytical solution. You'll have to solve it numerically. If you find that the numerical solutions are unstable, that might be an indication that there is no solution for those particular parameters. You could use Newton-Raphson on the function

$f(T)=(B_{0x}+B_{vx}T)\sin(\theta+\theta_{v}T)-(B_{0y}+B_{vy}T)\cos(\theta+\theta_{v}T)-r,$

and find the roots.

I don't know if there is a nice little theorem that would guarantee you a root, unless you can show that the proposed $f(T)$ changes sign on an interval. $f(T)$ is a continuous function of $T,$ so the Intermediate Value Theorem would (if the function does change sign on an interval) guarantee you a root in that interval.

Hope this helps.

8. This is unfortunate. My other solution is to approximate the actual endpoint of the line by making the end point move in a straight line to the final end point. This will change the length of the line but as long as the rotational velocity is relatively small it should work fine.

- Mike

9. Alright I got a formula that will approximate the position of the endpoint P of the "rotating" line CP by moving it linearly from its initial point Po to it's final point. Notice the arrow showing the path of P is now straight and not curved. This will produce inaccuracies but as long as the rotational velocity of the line is relatively small, it should work for my purposes.

Constants:
L: length of the rotating line (CP)
Po: initial position of the end point of the rotating line (CP)
Pox, Poy: components of Po
Pv: velocity of the end point of the rotating line (CP)
Pvx, Pvy: components of Pv
C: point the line rotates around
Cx, Cy: components of C
Bo: initial point/location of the circle
Box, Boy: components of Bo
Bv: velocity of the circle
Bvx, Bvy: components of Bv
θ: initial rotation of the rotating line (CP)
θv: rotational velocity of the rotating line (CP)

Variables:
P: position of the end point of the rotating line (CP) at time T
Px, Py: components of P
N: normal of the line rotating line (CP) at time T
Nx, Ny: components of N
B: point/location of the circle at time T
Bx, By: components of B
D: distance from the center of the circle (B) to the rotating line (CP) at time T

The arrow from Bo to B represents Bv or the velocity of the circle.
The arrow from Po to Prepresents Pv or the velocity of the endpoint.
The dashed line and circle represents a possible solution to the problem and I only put it there to help me think through the problem.

Same theory as before but instead of the endpoint having a rotational velocity, it has a linear one.

First I solve for T leaving the formula in its highest terms. One might argue that I must factor in the change of L over time T. However, L is canceled out and has no bearing on the result. To prove this I solved the formula in its lowest terms, pluging-in the values of all variables. You can see that L is canceled out and the final solution does not include L.

10. You have a very complicated formula there, but it is an explicit formula. I would try it out on some known cases and see if you get good approximations. Exercise the formula some, meaning put in some extreme cases, and see how the accuracy degrades.

11. This is actually for a physics engine I am writing from scratch. I figured out an efficient, yet lengthy, algorithm to solve my problem. Here is the test applet I made while trying to solve this:
http://yo1dog.comlu.com/flippertest.html

Here is a little bouncy pinball game I made for fun with my engine so far. Notice the very accurate high-speed collisions (although when you run applets like this online you never know what is going to happen. Simply refresh if it is messing up.):
http://yo1dog.comlu.com/pinballtest.html

12. It doesn't run very well. Is there a preferred browser? Pinball did occur to be as an application of this problem.

13. It runs fine for me in Firefox.
Windows 7 x64

14. Got it to work. Very nice! A little bit of a fast game for pinball, I think, but the action is still realistic. Good job! Did you have any other questions?

15. I made it fast to show off the accuracy of the high-speed collisions. :P

After reading an MIT graduate's dissertation on integrated physics I think I am set. If you have any resources on solutions to my flipper problem that would be helpful. The method I am using now has a large margin of error near the end.