MrApfelstrudel
MrApfelstrudel

Reputation: 157

Calculate time when a moving ball hits a moving line

I had a similar question but although I had the help of the community I couldn't solve it.

I have following problem: A ball moves towards a moving line. I want to know WHEN the ball collides with the line.

My best attempt to solve it: enter image description here

All variables: f(x) ... The line of the ball movement

g(x) ... The line before it moved

g1(x) ... The line after it moved

g2(x) ... The line after it moved + the radius (when the ball center hits this line, the ball border hits g1(x)

A (Ax, Ay) ... First point of the line before it moved

A1 (A1x, A1y) ... First point of the line after it moved

B (Bx, By) ... Second point of the line before it moved

B1 (B1x, B1y) ... Second point of the line after it moved

Vc (Vcx, Vxy) ... Speed of ball

Va (Vax, Vay) ... Speed for point A

Vb (Vbx, Vby) ... Speed for point B

r ... Radius of the ball

t ... Time of collision

  1. I calculate A1 and B1

A1 = (Ax + Vax * t, Ay + Vay * t)

B1 = (Bx + Vbx * t, By + Vby * t)

  1. I build the equation for g1(x)

g1: y1 = k1 * x + d1 (y = kx + d)

k1 = (B1y-A1y)/(B1x-A1x) (k = (dif between y)/(dif between x))

d1 = A1y - k1 * A1x (d = y - kx)

  1. I build the equation for g2(x)

g2: y2 = k1 * x + d2

  1. I calculate d2 using the distance equation between two parallel lines (see wikipedia). I know the distance between g1(x) and g2(x) is the radius of the ball

r = abs(d2 - d1)/sqrt(k1^2 + 1)

  1. I solve it for d2

  2. I build the equation for f(x)

f: y = k * x + d

k = Vcy/Vcx

d = Cy - k * Cx

  1. I calculate the intersection

f(x) = g2(x)

  1. I solve it for t

Microsoft Mathematics and my TI Nspire CX CAS are able to calculate every step EXCEPT step 8

Is there a easier way to do it?

Or do you know any programs that should be able to solve it?

(My old question: click me)

Upvotes: 2

Views: 132

Answers (1)

DSlomer64
DSlomer64

Reputation: 4283

Shucks. Derive has been working for a minute. It never comes back from such a trip. Is it possible there is still an error? Or that the equation can't be solved algebraically?

Here's the equation it was trying to solve (for two minutes):

enter image description here

Let's break it up:

Solve

enter image description here enter image description here

enter image description here enter image description here

for t.

I just remembered how to do subscripts, sort of:

enter image description here

enter image description here

Upvotes: 1

Related Questions