An Algorithm That Recognizes and Reproduces Distinct Types of Humanoid Motion Based on Periodically-Constrained Nonlinear PCA