Skip to content

Instantly share code, notes, and snippets.

@conundrumer
Created December 29, 2015 07:36
Show Gist options
  • Save conundrumer/a77860a3a871c2256427 to your computer and use it in GitHub Desktop.
Save conundrumer/a77860a3a871c2256427 to your computer and use it in GitHub Desktop.
va = velocity of point a
vb = velocity of point b
vp = velocity of point c (the point colliding with line ab) perpendicular to line ab
vm = velocity of the center of line ab
w = angular momentum
x = the position of point c on line ab (x==1 ? point c = point a; x==-1 ? point c = point b)
L = length of line ab divided by 2
L = dist(point a, point b) / 2
x = (L - dist(point a, point c) ) / L
w = ( va - vb + x*( (2/3)vp - (1/3)va - (1/3)vb ) ) / (2 + (2/3)x^2)
vm = (vp + va + vb) / 3
va’ = w*L + vm
vb’ = w*L + vm
vp’ = w*dist(center of line ab, point c) + vm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment