A Computational Model for Cursive Handwriting Based on the Minimization Principle