Text this: Switching algorithm to avoid attitude representation singularity