D
D
Denius (genius)2018-09-25 13:43:01
Java
Denius (genius), 2018-09-25 13:43:01

What physics formula does this code look like?

float
                    v1xp = b1.vx,
                    v1yp = b1.vy,
                    v2xp = b2.vx,
                    v2yp = b2.vy,
                    r = b1.r+b2.r;

            b1.vx = (float) (v1xp * Math.pow((b2.y-b1.y)/r,2) + v2xp * Math.pow((b1.x-b2.x)/r,2) + v1yp * (b2.x-b1.x)*(b1.y-b2.y)/Math.pow(r,2) + v2yp * (b2.x-b1.x)*(b2.y-b1.y)/Math.pow(r,2));         
            b1.vy = (float) (v1xp * (b2.y-b1.y)*(b1.x-b2.x)/Math.pow(r,2) + v2xp * (b2.y-b1.y)*(b2.x-b1.x)/Math.pow(r,2) + v1yp * Math.pow((b2.x-b1.x)/r,2) + v2yp * Math.pow((b1.y-b2.y)/r,2));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bask, 2018-09-25
@Conan_Doyle_SBINH

Law of conservation of momentum.
In particular, here is the elastic collision of two balls

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question