The biomechanics of the human body gives subjects a high degree of freedom in how they can execute movement. Nevertheless, subjects exhibit regularity in their movement patterns. One way to account for this regularity is to suppose that subjects select movement trajectories that are optimal in some sense. We adopt the principle that human movements are optimal and develop a general model for human movement patters that uses variational methods in the form of optimal control theory to calculate trajectories of movement trajectories of the body. We find that in this approach a constant of the motion that arises from the model and which plays a role in the optimal control model that is analogous to the role that the mechanical energy plays in classical physics. We illustrate how this approach works in practice by using it to develop a model of walking gait, making all the derivations and calculations in detail. We finally show that this optimal control model of walking gait recovers in an appropriate limit an existing model of walking gait which has been shown to provide good estimates of many observed characteristics of walking gait.