Changeset View
Changeset View
Standalone View
Standalone View
kstars/tools/starhopper.h
Context not available. | |||||
15 | * * | 15 | * * | ||
---|---|---|---|---|---|
16 | ***************************************************************************/ | 16 | ***************************************************************************/ | ||
17 | 17 | | |||
18 | #ifndef _STARHOPPER_H_ | 18 | #pragma once | ||
19 | #define _STARHOPPER_H_ | | |||
20 | 19 | | |||
21 | /** | 20 | #include <QHash> | ||
22 | *@class StarHopper | 21 | #include <QList> | ||
23 | *@short Helps planning star hopping | 22 | | ||
24 | *@version 1.0 | 23 | class QStringList; | ||
25 | *@author Akarsh Simha | | |||
26 | */ | | |||
27 | 24 | | |||
28 | #include "skypoint.h" | 25 | class SkyPoint; | ||
29 | #include "skyobject.h" | 26 | class StarObject; | ||
30 | #include "starobject.h" | | |||
31 | 27 | | |||
28 | /** | ||||
29 | * @class StarHopper | ||||
30 | * @short Helps planning star hopping | ||||
31 | * | ||||
32 | * @version 1.0 | ||||
33 | * @author Akarsh Simha | ||||
34 | */ | ||||
32 | class StarHopper | 35 | class StarHopper | ||
33 | { | 36 | { | ||
34 | public: | 37 | public: | ||
35 | /** | 38 | /** | ||
36 | *@short Computes path for Star Hop | 39 | * @short Computes path for Star Hop | ||
37 | *@param src SkyPoint to source of the Star Hop | 40 | * @param src SkyPoint to source of the Star Hop | ||
38 | *@param dest SkyPoint to destination of the Star Hop | 41 | * @param dest SkyPoint to destination of the Star Hop | ||
39 | *@param fov__ Field of view within which stars are considered | 42 | * @param fov__ Field of view within which stars are considered | ||
40 | *@param maglim__ Magnitude limit of stars to consider | 43 | * @param maglim__ Magnitude limit of stars to consider | ||
41 | *@param metadata_ Directions for starhopping | 44 | * @param metadata_ Directions for starhopping | ||
42 | *@return QList of StarObject pointers which are the resultant path to Star Hop | 45 | * @return QList of StarObject pointers which are the resultant path to Star Hop | ||
43 | *@note The StarObjects in the list returned are mutable and not constant | 46 | * @note The StarObjects in the list returned are mutable and not constant | ||
44 | */ | 47 | */ | ||
45 | QList<StarObject *> *computePath(const SkyPoint &src, const SkyPoint &dest, float fov__, float maglim__, | 48 | QList<StarObject *> *computePath(const SkyPoint &src, const SkyPoint &dest, float fov__, float maglim__, | ||
46 | QStringList *metadata_ = 0); | 49 | QStringList *metadata_ = nullptr); | ||
47 | 50 | | |||
48 | private: | 51 | protected: | ||
49 | float fov; | 52 | // Returns a list of constant StarObject pointers which form the resultant path of Star Hop | ||
50 | float maglim; | 53 | QList<const StarObject *> computePath_const(const SkyPoint &src, const SkyPoint &dest, float fov_, float maglim_, | ||
51 | QString starHopDirections; | 54 | QStringList *metadata = nullptr); | ||
52 | | ||||
53 | // Useful for internal computations | | |||
54 | SkyPoint const *start; | | |||
55 | SkyPoint const *end; | | |||
56 | QHash<const SkyPoint *, const SkyPoint *> came_from; // Used by the A* search algorithm | | |||
57 | QList<StarObject const *> result_path; | | |||
58 | 55 | | |||
56 | private: | ||||
59 | /** | 57 | /** | ||
60 | *@short The cost function for hopping from current position to the a given star, in view of the final destination | 58 | * @short The cost function for hopping from current position to the a given star, in view of the final destination | ||
61 | *@param curr Source SkyPoint | 59 | * @param curr Source SkyPoint | ||
62 | *@param next Next point in the hop. | 60 | * @param next Next point in the hop. | ||
63 | *@note If 'next' is neither the starting point of the hop, nor | 61 | * @note If 'next' is neither the starting point of the hop, nor | ||
64 | * the ending point, it _has_ to be a StarObject. A dynamic cast | 62 | * the ending point, it _has_ to be a StarObject. A dynamic cast | ||
65 | * followed by a Q_ASSERT will ensure this. | 63 | * followed by a Q_ASSERT will ensure this. | ||
66 | */ | 64 | */ | ||
67 | float cost(const SkyPoint *curr, const SkyPoint *next); | 65 | float cost(const SkyPoint *curr, const SkyPoint *next); | ||
68 | 66 | | |||
69 | /** | 67 | /** | ||
70 | *@short For internal use by the A* Search Algorithm. Completes | 68 | * @short For internal use by the A* Search Algorithm. Completes | ||
71 | * the star-hop path. See | 69 | * the star-hop path. See http://en.wikipedia.org/wiki/A*_search_algorithm for details | ||
72 | * http://en.wikipedia.org/wiki/A*_search_algorithm for details | 70 | */ | ||
73 | */ | | |||
74 | void reconstructPath(SkyPoint const *curr_node); | 71 | void reconstructPath(SkyPoint const *curr_node); | ||
75 | 72 | | |||
73 | float fov { 0 }; | ||||
74 | float maglim { 0 }; | ||||
75 | QString starHopDirections; | ||||
76 | // Useful for internal computations | ||||
77 | SkyPoint const *start { nullptr }; | ||||
78 | SkyPoint const *end { nullptr }; | ||||
79 | QHash<const SkyPoint *, const SkyPoint *> came_from; // Used by the A* search algorithm | ||||
80 | QList<StarObject const *> result_path; | ||||
76 | QHash<SkyPoint const *, QString> patternNames; // if patterns were identified, they are added to this hash. | 81 | QHash<SkyPoint const *, QString> patternNames; // if patterns were identified, they are added to this hash. | ||
77 | | ||||
78 | protected: | | |||
79 | //Returns a list of constant StarObject pointers which form the resultant path of Star Hop | | |||
80 | QList<const StarObject *> computePath_const(const SkyPoint &src, const SkyPoint &dest, float fov_, float maglim_, | | |||
81 | QStringList *metadata = 0); | | |||
82 | }; | 82 | }; | ||
83 | | ||||
84 | #endif | | |||
Context not available. |