make lean calc more robust
This commit is contained in:
parent
8cd901dadc
commit
851f2fb650
1 changed files with 3 additions and 1 deletions
|
@ -64,8 +64,10 @@ pub(super) fn cyber_lean(
|
|||
let v2_r = v_squared / radius;
|
||||
let tan_theta = (v2_r / gravity).clamp(-FRAC_PI_3, FRAC_PI_3);
|
||||
|
||||
if v2_r.is_normal() {
|
||||
if tan_theta.is_finite() && !tan_theta.is_subnormal() {
|
||||
lean.lean = tan_theta.atan().clamp(-FRAC_PI_4, FRAC_PI_4);
|
||||
} else {
|
||||
lean.lean = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue