The Pythagorean theorem and trigonometry in space