From b84c36c91ab49ec69a9fc28cc165b78fb73a77e3 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Sat, 3 May 2025 10:14:53 -0400 Subject: [PATCH] Add GetRadarBeamAltititude into geographic lib --- .../source/scwx/qt/util/geographic_lib.cpp | 20 +++++++++++++++++++ .../source/scwx/qt/util/geographic_lib.hpp | 15 ++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/scwx-qt/source/scwx/qt/util/geographic_lib.cpp b/scwx-qt/source/scwx/qt/util/geographic_lib.cpp index bfaf408f..8181f34c 100644 --- a/scwx-qt/source/scwx/qt/util/geographic_lib.cpp +++ b/scwx-qt/source/scwx/qt/util/geographic_lib.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -289,6 +290,25 @@ bool AreaInRangeOfPoint(const std::vector& area, return GetDistanceAreaPoint(area, point) <= distance; } +units::length::meters +GetRadarBeamAltititude(units::length::meters range, + units::angle::degrees elevation, + units::length::meters height) +{ + static const units::length::meters earthRadius {6367444 * 4/3}; + + height += earthRadius; + + const double elevationRadians = + units::angle::radians(elevation).value(); + const auto altitudeSquared = + (range * range + height * height + + 2 * range * height * std::sin(elevationRadians)); + + return units::length::meters(std::sqrt(altitudeSquared.value())) - + earthRadius; +} + } // namespace GeographicLib } // namespace util } // namespace qt diff --git a/scwx-qt/source/scwx/qt/util/geographic_lib.hpp b/scwx-qt/source/scwx/qt/util/geographic_lib.hpp index 5038d9a9..1d6cc38e 100644 --- a/scwx-qt/source/scwx/qt/util/geographic_lib.hpp +++ b/scwx-qt/source/scwx/qt/util/geographic_lib.hpp @@ -121,6 +121,21 @@ bool AreaInRangeOfPoint(const std::vector& area, const common::Coordinate& point, const units::length::meters 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 +GetRadarBeamAltititude(units::length::meters range, + units::angle::degrees elevation, + units::length::meters height); + + } // namespace GeographicLib } // namespace util } // namespace qt