Kstars

starhopper.h
1 /*
2  SPDX-FileCopyrightText: 2010 Akarsh Simha <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QHash>
10 #include <QList>
11 
12 class QStringList;
13 
14 class SkyPoint;
15 class StarObject;
16 
17 /**
18  * @class StarHopper
19  * @short Helps planning star hopping
20  *
21  * @version 1.0
22  * @author Akarsh Simha
23  */
25 {
26  public:
27  /**
28  * @short Computes path for Star Hop
29  * @param src SkyPoint to source of the Star Hop
30  * @param dest SkyPoint to destination of the Star Hop
31  * @param fov__ Field of view within which stars are considered
32  * @param maglim__ Magnitude limit of stars to consider
33  * @param metadata_ Directions for starhopping
34  * @return QList of StarObject pointers which are the resultant path to Star Hop
35  * @note The StarObjects in the list returned are mutable and not constant
36  */
37  QList<StarObject *> *computePath(const SkyPoint &src, const SkyPoint &dest, float fov__, float maglim__,
38  QStringList *metadata_ = nullptr);
39 
40  protected:
41  // Returns a list of constant StarObject pointers which form the resultant path of Star Hop
42  QList<const StarObject *> computePath_const(const SkyPoint &src, const SkyPoint &dest, float fov_, float maglim_,
43  QStringList *metadata = nullptr);
44 
45  private:
46  /**
47  * @short The cost function for hopping from current position to the a given star, in view of the final destination
48  * @param curr Source SkyPoint
49  * @param next Next point in the hop.
50  * @note If 'next' is neither the starting point of the hop, nor
51  * the ending point, it _has_ to be a StarObject. A dynamic cast
52  * followed by a Q_ASSERT will ensure this.
53  */
54  float cost(const SkyPoint *curr, const SkyPoint *next);
55 
56  /**
57  * @short For internal use by the A* Search Algorithm. Completes
58  * the star-hop path. See https://en.wikipedia.org/wiki/A*_search_algorithm for details
59  */
60  void reconstructPath(SkyPoint const *curr_node);
61 
62  float fov { 0 };
63  float maglim { 0 };
64  QString starHopDirections;
65  // Useful for internal computations
66  SkyPoint const *start { nullptr };
67  SkyPoint const *end { nullptr };
68  QHash<const SkyPoint *, const SkyPoint *> came_from; // Used by the A* search algorithm
69  QList<StarObject const *> result_path;
70  QHash<SkyPoint const *, QString> patternNames; // if patterns were identified, they are added to this hash.
71 };
Helps planning star hopping.
Definition: starhopper.h:24
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
QList< StarObject * > * computePath(const SkyPoint &src, const SkyPoint &dest, float fov__, float maglim__, QStringList *metadata_=nullptr)
Computes path for Star Hop.
Definition: starhopper.cpp:16
subclass of SkyObject specialized for stars.
Definition: starobject.h:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:58 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.