/* Uses the scalar orientation value to convert from chip frame to body frame and apply appropriate scaling.  */
void inv_convert_to_body_with_scale(unsigned short orientation, long sensitivity, const long *input, long *output)
/* Uses the scalar orientation value to convert from chip frame to body frame and apply appropriate scaling.  */
void inv_convert_to_body_with_scale(unsigned short orientation, long sensitivity, const long *input, long *output)
{
    output[0] = inv_q30_mult(input[orientation & 0x03] *
                             SIGNSET(orientation & 0x004), sensitivity);
    output[1] = inv_q30_mult(input[(orientation>>3) & 0x03] *
                             SIGNSET(orientation & 0x020), sensitivity);
    output[2] = inv_q30_mult(input[(orientation>>6) & 0x03] *
                             SIGNSET(orientation & 0x100), sensitivity);
}