Global magnetic attitude control of spacecraft