File indexing completed on 2024-04-21 14:46:53

0001 /*
0002     SPDX-FileCopyrightText: 2021 Hy Murveit <hy@murveit.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 // Example usage:
0008 //
0009 // double az1 = ..., alt1 = ..., az2 = ..., alt2 = ...;
0010 // GreatCircle gc(az1, alt1, az2, alt2);
0011 // double az, alt;
0012 // gc.waypoint(0.75, &az, &alt);
0013 //
0014 // az and alt will contain the coordinates for a waypoint 75% of the way
0015 // between az1,alt1 and az2,alt2 along a great circle path.
0016 // See https://en.wikipedia.org/wiki/Great-circle_navigation
0017 
0018 #pragma once
0019 
0020 #include <QObject>
0021 
0022 /**
0023  * @brief A class to compute points along a great circle from one az/alt to another.
0024  * @author Hy Murveit
0025  * @version 1.0
0026  */
0027 class GreatCircle
0028 {
0029     public:
0030         /**
0031          * @brief Construct a GreatCircle object for a path between az1,alt1 to az2,alt2
0032          * @param az1  starting azimuth  value (degrees).
0033          * @param alt1 starting altitude value (degrees).
0034          * @param az2    ending azimuth  value (degrees).
0035          * @param alt2   ending altitude value (degrees).
0036          */
0037         GreatCircle(double az1, double alt1, double az2, double alt2);
0038 
0039         /**
0040          * @brief Return the azimuth and altitude for a waypoint
0041          * @param fraction the desired fraction of the total path
0042          * @param az the returned azimuth value (degrees)
0043          * @param alt the returned altitude value (degrees)
0044          */
0045         void waypoint(double fraction, double *az, double *alt);
0046 
0047     private:
0048         // These are values computed in the constructor needed by all waypoints.
0049         double sigma01, sigma02, lambda0;
0050         double cosAlpha0, sinAlpha0;
0051 };