Well, it's been a year since I took basic physics and I need some help. I'm working on a traffic simulation for a research job I have and I'm getting stuck trying to figure out the best way to do something.
Basically, I have two cars distance d apart each with a velocity and constant acceleration (well I'll call it constant for simplicity).
Now, if car number 1 is behind car number 2 and is traveling faster but has a negative acceleration, can it slow down before it hits car number 2?
So there is:
car1: s1 (position), v1, a1
car2: s2, v2, a2
d
conditions: s1 < s2, a1 < 0, and v1 > v2
I remember doing problems like this in physics, but I'm stuck.
EDIT:
I think I've figured it out,
the time to reach the same velocity is:
because
and if I just check that the distance of car1 at time t is less than the distance of car2 at time t + initial distance, then I know that the cars will not collide.
My problem is, if the accelerations are the same, it's division by 0 and I can't figure out an alternative equation or what that would really mean.
EDIT2:
Ok, I guess my calculation for time isn't really the time I want. What time would I need to plug in to:
To see if the car behind would hit the car in front?
Basically, I have two cars distance d apart each with a velocity and constant acceleration (well I'll call it constant for simplicity).
Now, if car number 1 is behind car number 2 and is traveling faster but has a negative acceleration, can it slow down before it hits car number 2?
So there is:
car1: s1 (position), v1, a1
car2: s2, v2, a2
d
conditions: s1 < s2, a1 < 0, and v1 > v2
I remember doing problems like this in physics, but I'm stuck.
EDIT:
I think I've figured it out,
the time to reach the same velocity is:
| Code: |
|
v1 - v2 t = _______ a2 - a1 |
because
| Code: |
| vf = vi + at |
and if I just check that the distance of car1 at time t is less than the distance of car2 at time t + initial distance, then I know that the cars will not collide.
My problem is, if the accelerations are the same, it's division by 0 and I can't figure out an alternative equation or what that would really mean.
EDIT2:
Ok, I guess my calculation for time isn't really the time I want. What time would I need to plug in to:
| Code: |
|
s = vi*t + 1/2at^2 |
To see if the car behind would hit the car in front?

