Fits a Principal Curve in Arbitrary Dimension