Add GetRadarBeamAltititude into geographic lib

This commit is contained in:
AdenKoperczak 2025-05-03 10:14:53 -04:00
parent 22ed4c36fc
commit b84c36c91a
No known key found for this signature in database
GPG key ID: 9843017036F62EE7
2 changed files with 35 additions and 0 deletions

View file

@ -2,6 +2,7 @@
#include <scwx/util/logger.hpp>
#include <numbers>
#include <cmath>
#include <GeographicLib/Gnomonic.hpp>
#include <geos/algorithm/PointLocation.h>
@ -289,6 +290,25 @@ bool AreaInRangeOfPoint(const std::vector<common::Coordinate>& area,
return GetDistanceAreaPoint(area, point) <= distance;
}
units::length::meters<double>
GetRadarBeamAltititude(units::length::meters<double> range,
units::angle::degrees<double> elevation,
units::length::meters<double> height)
{
static const units::length::meters<double> earthRadius {6367444 * 4/3};
height += earthRadius;
const double elevationRadians =
units::angle::radians<double>(elevation).value();
const auto altitudeSquared =
(range * range + height * height +
2 * range * height * std::sin(elevationRadians));
return units::length::meters<double>(std::sqrt(altitudeSquared.value())) -
earthRadius;
}
} // namespace GeographicLib
} // namespace util
} // namespace qt

View file

@ -121,6 +121,21 @@ bool AreaInRangeOfPoint(const std::vector<common::Coordinate>& area,
const common::Coordinate& point,
const units::length::meters<double> distance);
/**
* Get the altitude of the radar beam at a given distance, elevation and height
*
* @param [in] range The range to the radar site
* @param [in] elevation The elevation of the radar site
* @param [in] height The height of the radar site
*
* @return The altitude of the radar at that range
*/
units::length::meters<double>
GetRadarBeamAltititude(units::length::meters<double> range,
units::angle::degrees<double> elevation,
units::length::meters<double> height);
} // namespace GeographicLib
} // namespace util
} // namespace qt