## Calculating the distance between two points with the Pythagorean Theorem

So, before we get started, I need to define some things.

**Right Triangle**:

A right triangle is a triangle with a right angle.

**Pythagorean Theorem
**The Pythagorean Theorem says that a^2+b^2=c^2. a and b are the two shorter sides of the right triangle. The long side is called the hypotenuse. From now on we will refer to c as h. If we want to get h, instead of h^2, we can do h=\sqrt {a^2+b^2}

Ok. Now that we’re done with that, we can start actually calculating distance. This part is pretty simple. Imagine we have a cat that wants to get to a mouse, but needs to know how far away it is. The cat is at 0,0, and the mouse is at 5,5. Let’s call the cat’s x and y “cx” and “cy” , and let’s call the mouse’s x and y “mx” and “my”.In many of these equations, I will be using || a lot. If a number is between those bars, it means that it will be made positive (|-5|=5). First, we find |cx-mx|, and we find |cy-my|. These are the differences between the x values and the y values. Now we take those numbers (let’s call them “dx” and “dy”). To get h^2, we do h^2=dx^2 + dy^2. Now we can do h=\sqrt {h^2}. We are done. h is our distance. This seems long, but we just produced a short formula to find distance. Here is the completed formula: h=\sqrt {(|cx-mx|)^2+(|cy-my|)^2}

For those of you still having trouble, this might help explain why you can’t just add dx and dy, and why you are using right triangles: