Elastic Collision Formula in Java
Posted
by
Shijima
on Game Development
See other posts from Game Development
or by Shijima
Published on 2014-06-04T02:09:22Z
Indexed on
2014/06/04
3:40 UTC
Read the original article
Hit count: 183
I'm trying to write a Java formula based on this tutorial: 2-D elastic collisions without Trigonometry. I am in the section "Elastic Collisions in 2 Dimensions". In step 1, it mentions "Next, find the unit vector of n, which we will call un. This is done by dividing by the magnitude of n".
My below code represents the normal vector of 2 objects (I'm using a simple array to represent the normal vector), but I am not really sure what the tutorial means by dividing the magnitude of n to get the un.
int[] normal = new int[2];
normal[0] = ball2.x - ball1.x;
normal[1] = ball2.y - ball1.y;
Can anyone please explain what un is, and how I can calculate it with my array in Java?
© Game Development or respective owner