Ptolemy's theorem and extensions