Control of the spatial motion of a multilink inverted pendulum using a torque applied to the first link