Inverse Simulation of Attitude Maneuvers for Underactuated Rigid Spacecraft