Pythagorean theorem and distance between points