Attitude control of a flexible spacecraft