An effective procedure is presented for the determination of the optimal control input for maneuvers of a mechanical system with internal degrees of freedom such as a slewing of a spacecraft with flexible appendages or a displacement of a reservoir with a liquid for the case of constraint on velocity of the maneuver. The dynamic equations of motion are formulated, allowing taking into account the flexible elements using the quasistatical approach. The problem of optimal reorientation for rest-to-rest maneuvers is formulated using the objective function, which results in the minimal acceleration of the relative motion of the attached flexible elements during the maneuver. The new features and advantages of the proposed approach are the use of a not widely known objective function for the optimal control problem, which has a clear physical interpretation, and analytical solving the constrained optimization problem by the method based on parameterization of the functional for the multi-point boundary value problem. The solution is illustrated graphically. This analytical solution is applicable also for vibrations rejection at shaping the law of deployment of flexible constructions on spacecraft. It is useful for input shaping motion laws of objects of the ground-based transport in the modes of braking and acceleration for minimization of relative accelerations of passengers and goods.