|
-
Senior Member
Doesn't seem like the last reply really addressed the issue - don't think the OP really knows the position where the car intersects the circle. (IE doesn't know the values of car._x, car._y).
Denote vector quantities with []. You can solve the problem by writing the position of the car in parametric form:
[C(t)] = [C0] + [Cdir]*t
[C(t)] is cars position at time t.
[C0] is cars position at t=0 (denoted x,y in your original figure)
[Cdir] is a unit vector that points in the direction of the cars motion (denoted dx,dy in your figure, but you must normalize it)
You are looking for the time at which the distance between the car and the center of the circle (denoted [B]) is R. Or equivalently, when the distance^2 is equal to R^2:
dot( [C0]-[B]+[Cdir]t, [C0]-[B]+[Cdir]t) = R*R
This is a quadratric equation in t. Solve for t using quadratic formula:
t = (-b +/- sqrt(bb-4ac) ) / 2a
where:
a = 1
b = 2 * dot( [C0]-[B], [Cdir] )
c = dot([C0]-[B],[C0]-[B]) - R*R
(ie the distance^2 between cars start and circles center, minus R*R)
There will be two roots for t - pick the one that's positive. (The negative root indicates the time the car intersected the circle as it entered it in the past). Once you know t, you know the position [C(t)] at the time of intersection. You can plug those numbers into dudeqwerty's solution.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|