Code:

```
if (chairrot == 1) {
VECTOR3 weight_v;
GetWeightVector(weight_v);
double const current_g = MAGNETUDE(weight_v) / GetMass();
double const angle = ((current_g < 0.98) ? PI : atan2(weight_v.x, weight_v.y));
double const radians = (angle / PI);
{
double const anim = 1 - abs(((radians < 0) ? -0.5 : 0.5) + abs(radians / 2));
SetAnimation(anim_PILOTCHAIR, anim);
SetAnimation(anim_COPILOTCHAIR, anim);
sprintf(oapiDebugString(), "chairrot %d; anim %lf;", chairrot, anim);
}
}
```