The formula for two cars crashing

i currently have no access to my pc right now i cant provide screenshots

so when two cars bump into eachother how to get the relative speed they bumped eachother with?

its not just same and opposite direction there is an angel so the formula of
v+v2 or v-v2 will not work

1 Like

For angles you use Dot Products.

Assuming you have 2 cars with their velocity in variables like so:

local CarA_Velocity = -- Car A's velocity.
local CarB_Velocity = -- Car B's velocity.

local Dot = math.cos(CarA_Velocity:Dot(CarB_Velocity)) -- Returns the angle in radians.
1 Like

It is the difference of their velocities. If both cars travel at 30 mph in the same direction, the difference is zero. If they travel in opposite directions, it will be 60 mph. This can be used to calculate the forced between the cars if they collide.

What exactly do you mean by “relative speed”? Do you mean the impulse force at impact, or do you just want the relative velocity?

If you want the relative linear velocity it’s as simple as objectB.AssemblyLinearVelocity - objectA.AssemblyLinearVelocity but things can quickly become more difficult unless you know more about the collision.

What’s your exact use case here? Would be easier to figure out what you need to do with more info on what you’re hoping to achieve

if you go in the same direction with the same speed relative speed is 0 if you go in the opposite direction its the sum of both of you
the problem is how to calculate that speed for different angles like 30 or 72

i might try that later thank you

now imagine you hit someone with the angle of 30 thats the problem

Velocity is a vector quantity (it has direction as well as magnitude), so there isn’t a need to consider angles as long as you have the components of velocity. If you just have the angle, you can just use some trig to get the x and y components.

(Also, is this stuff for modeling collisions?)

I’m assuming you want the resultant velocity after a collision. In which case I’ll assume the floor is smooth and the cars to be spheres with coefficient of restitution (how much it bounces) to be 0.84.
Use Newton’s Third Law - for every force in nature there is an equal and opposite force.

Assuming the first body has:

  • Mass = m
  • Initial speed = u
  • Angle = 30

And the second body has:

  • Mass = 3m
  • Initial speed = 2u
  • Angle = 75

First, split the velocity into its x and y components via the angle
image
(Note that the y component will remain the same since there is no opposing force so you only need to be concerned about the x component)
Now we use conservation of momentum ((m1)x(u1) + (m2)x(u2) = (m1)x(v1) + (m2)x(v2) where v1 and v2 are the final speeds) to calculate the resultant horizontal speeds (note that (u2) is negative since it is travelling in the opposite direction):
mucos(30) + 3m(-2ucos(75)) = m(v1) + 3m(v2) = -0.68689mu
So (v1) + 3(v2) = -0.68689u

Using the coefficient of restitution:
e = (final speed of object 2 - final speed of object 1)/(initial speed of object 1 - initial speed of object 2)
0.84 = ((v2) - (v1))/(u - -2u)

So we have the simultaneous equations:
(v2) - (v1) = 3x0.84u = 2.52u
and
(v1) + 3(v2) = -0.68689u
Adding these together gives
4(v2) = 1.83311u
So (v2) = 0.458u (rounded cause I cba)
And plugging it back into the equation gives
(v1) = (v2) - 2.52u = -2.062u
image

Now use the Pythagorean Theorem to calculate the final velocity:
Object 1: sqrt((2.062u)^2 + (usin30)^2) = 2.1217549u
Object 2: sqrt((0.458u)^2 + (2usin75)^2) = 1.9854u

And the angles can be calculated using trig again:
Object 1: arctan((usin30)/(2.062u)) = 13.63 degrees
Object 2: arctan((2usin75)/0.458u) = 76.66 degrees

So this is the final result:
image

Please excuse the diagrams and handwriting; I dropped art for a reason :sob:. If you’d like to go a step further use the formulae KE = 0.5mv^2, P = F/A and density to more accurately determine the resultant trajectory.

1 Like