I'm writing a Java formula based on this tutorial: 2-D elastic collisions without Trigonometry. I am in the section "Elastic Collisions in 2 Dimensions". Part of step 1 says:
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).
int[] normal = new int[2];
normal[0] = ball2.x - ball1.x;
normal[1] = ball2.y - ball1.y;
I am unsure what the tutorial means by dividing the magnitude of n to get the un.
What is un? How can I calculate it with my Java array?