One of the formulas, that you will use all the time, is the formula that calculates the distance between two points on the screen. As far as I know it is an old invention from the old Greeks, more specific the guy called Pythagoras. He made a discovery, that ensured his fame long into this century - the Pythagorean Theorem.
Used in geometry, this theorem states:
In a right-angled triangle the area of the square on the hypotenuse is equal to the sum of the areas of the squares of the other two sides.
The odd word here is the hypotenuse. This is the name for the side that is opposite to the right angle. As you can read, the theorem deals with a bunch of squares - rectangles with equal width and height - and the relation between the hypotenuse, and the two others. So in plain English the theorem states:
If you start from the right angle, and make two squares extend with the length of of the sides that extends from it, the sum of these two areas combined is the same as one single square with a width of the long side on the opposite side of the right angle.
You see, I tried to explain it simpler that the original theorem, but failed miserably. Maybe both quotes combined with the formula and a diagram does the job:
a2 + b2 = c2
The tricky part here is that we just want the side and not an area. Luckily it isn't even a tricky part, because there is an easy way to calculate the side of a square, based on the area - the square root - well thought name. The root for the definition of a square is to take a length, and multiply it with it self. So we end up with
c = sqr((a * a) + (b * b))
C is almost always the length, we wan't to know, and A and B is almost always the values w know, because from any given two points you can draw a horizontal and vertical line. Find where the lines intersect, and measure the length from the intersection and out to points.
If you want to find a distance between two points, this is how it is achieved in:
Some of the more visual oriented languages like ActionScript and Processing has specific methods for calculating distances. ActionScript has a Point class, that only deals with points and the relation between them. In the same manner, Processing has a dist() method that that calculates the distance based on the given x- and y- coordinates, like this: