Car collision physics, don't know where I'm going wrong

Hey guys,

I have been given an equation by my tutor for car collision physics.

Only, I only understand half of his equation. It does not add up. I'm getting a problem of increasing acceleration.

//Math

Constants - Mass - m1, m2

Inputs - Horizontal, Vertical. Initial, final - v1I, v1F, v2I, v2F

Parameters - e between 0 and 1

v1F = m1 * v1I + m2 * v2I - m2 * e * (v2I - v1I)

------------------------------------------

m1 + m2

v2F = v1F + e * (v2I - v1I)

//

I ended up with something quite different (2nd bit), I just can't figure what that second bit is, he said it's for the 2nd car (v2 velocity of 2nd car). But instead the acceleration freezes my computer it gets so high.

Code:

`vnew = (mass * vspeed + other.mass + other.vspeed - other.mass * E * (other.vspeed - vspeed)) / mass + other.mass;`

hnew = (mass * hspeed + other.mass + other.hspeed - other.mass * E * (other.hspeed - hspeed)) / mass + other.mass;

other.vnew = (other.mass * other.vspeed + mass + vspeed - mass * E * (vspeed - other.vspeed)) / other.mass + mass;

other.hnew = (other.mass * other.hspeed + mass + hspeed - mass * E * (hspeed - other.hspeed)) / other.mass + mass;

vspeed = vnew;

hspeed = hnew;

other.vspeed = other.vnew;

other.hspeed = other.hnew;

I split it up into "vnew, hnew" to make it more clear what v1I and v1F (vspeed, hspeed) is.

Just ask if you need more info, it seems to be pretty standard physics math.