Pythagorean theorem should be used in this case.
a² + b² = c² where a and b are the sides of the triangle and c is the hypotenuse
This theorem is typically taught as a way to calculate the hypotenuse of a triangle (which is what you are referring to)
But it may mean much more to you if you realize that this is an equation to describe shortest distance from the origin to some coordinate. I have found myself using it more as a way to find distance than I do to measure a length of a physical shape.