Pythagorean theorem in 3D