public Disk(VecD pos, VecD v, int mass, int radius) { Pos = pos; V = v; Mass = mass; Radius = radius; }
private static VecD ComputeImpulse(VecD p1, VecD v1, int m1, VecD p2, VecD v2, int m2) { var dp = p2 - p1; var dv = v2 - v1; var drdr = dp.ScalarProd(dp); var dvdr = dp.ScalarProd(dv); var massCoefficient = (m1 + m2) / (double)(m1 * m2); return(2 * dvdr / (massCoefficient * drdr) * dp); }
private static Tuple <VecD, VecD> BouncedSpeed(VecD v1, int m1, VecD v2, int m2, VecD impulse) { return(Tuple.Create(v1 + impulse / m1, v2 - impulse / m2)); }