Skip to content

Commit

Permalink
Merge pull request #35 from SearchAndRescue2/fix-AGL-altitude-calcula…
Browse files Browse the repository at this point in the history
…tion

Fix AGL altitude calculation for fixed landing gears and reorganize t…
  • Loading branch information
hsanjuan committed Jul 31, 2023
2 parents 6656be1 + 86c7640 commit 74deace
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions src/sardraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3791,31 +3791,23 @@ static void SARDrawOutsideAttitude(
y += 18;

/* Altitude AGL */
if(aircraft->landed)
v1 = 0.0f;
else
v1 = (float)MAX(
-(((((gear_state == 1) || (gear_state == 2)) ? aircraft->gear_height : 0.0f) +
aircraft->belly_height) +
aircraft->center_to_ground_height), 0.0f
);
switch(opt->units)
{
case SAR_UNITS_METRIC:
if(aircraft->landed)
v1 = 0.0f;
else
v1 = (float)MAX(
-((((gear_state == 1) ? aircraft->gear_height : 0.0f) +
aircraft->belly_height) +
aircraft->center_to_ground_height), 0.0f
);
units_str1 = "M";
break;

case SAR_UNITS_METRIC_ALT_FEET:
default:
if(aircraft->landed)
v1 = 0.0f;
else
v1 = (float)SFMMetersToFeet(
MAX(
-((((gear_state == 1) ? aircraft->gear_height : 0.0f) +
aircraft->belly_height) +
aircraft->center_to_ground_height), 0.0f
)
);
v1 = (float)SFMMetersToFeet(v1);
units_str1 = "FT";
break;
}
Expand Down

0 comments on commit 74deace

Please sign in to comment.