LOST  0.0.1
LOST: Open-source Star Tracker
star-utils.hpp
Go to the documentation of this file.
1 #ifndef STAR_UTILS_H
2 #define STAR_UTILS_H
3 
4 #include <vector>
5 
6 #include "attitude-utils.hpp"
7 #include "serialize-helpers.hpp"
8 
9 namespace lost {
10 
12 class CatalogStar {
13 public:
14  CatalogStar() = default;
15 
22  CatalogStar(decimal raj2000, decimal dej2000, int magnitude, int name) :
23  spatial(SphericalToSpatial(raj2000, dej2000)), magnitude(magnitude), name(name) {}
24 
27 
37  int magnitude;
42  int name;
43 };
44 
49 class Star {
50 public:
53 
56 
58  Star() : Star(DECIMAL(0.0), DECIMAL(0.0), DECIMAL(0.0)) {};
59 
70  int magnitude;
71  // eccentricity?
72 };
73 
79 public:
85 
86  // does not check weight
87  bool operator==(const StarIdentifier& other) const {
88  return starIndex == other.starIndex &&
89  catalogIndex == other.catalogIndex;
90  }
91 
93  int starIndex;
98 };
99 
100 typedef std::vector<CatalogStar> Catalog;
101 typedef std::vector<Star> Stars;
102 typedef std::vector<StarIdentifier> StarIdentifiers;
103 
104 void SerializeCatalog(SerializeContext *, const Catalog &, bool inclMagnitude, bool inclName);
105 // sets magnited and name to whether the catalog in the database contained magnitude and name
106 Catalog DeserializeCatalog(DeserializeContext *des, bool *inclMagnitudeReturn, bool *inclNameReturn);
107 Catalog::const_iterator FindNamedStar(const Catalog &catalog, int name);
108 
111 decimal MagToBrightness(int magnitude);
112 
132 Catalog NarrowCatalog(const Catalog &, int maxMagnitude, int maxStars, decimal minSeparation);
133 
134 }
135 
136 #endif
A star from the Bright Star Catalog.
Definition: star-utils.hpp:12
CatalogStar(decimal raj2000, decimal dej2000, int magnitude, int name)
Create a CatalogStar using its celestial/spherical coordinates.
Definition: star-utils.hpp:22
int name
A unique number which unambiguously identifies the catalog star.
Definition: star-utils.hpp:42
CatalogStar(Vec3 spatial, int magnitude, int name)
Definition: star-utils.hpp:25
int magnitude
The magnitude of the star, with the decimal point shifted two places right.
Definition: star-utils.hpp:37
Vec3 spatial
The point on the unit sphere where the star lies.
Definition: star-utils.hpp:32
CatalogStar()=default
A "centroid" detected in an image.
Definition: star-utils.hpp:49
decimal radiusY
Approximate vertical radius of the bright area in pixels.
Definition: star-utils.hpp:65
Star(decimal x, decimal y, decimal radiusX, decimal radiusY, int magnitude)
Definition: star-utils.hpp:51
Star()
Create a zeroed-out star. Fields should be set immediately after construction.
Definition: star-utils.hpp:58
Vec2 position
The (x,y) pixel coordinates in the image (top left is 0,0)
Definition: star-utils.hpp:58
Star(decimal x, decimal y, decimal radiusX)
Convenience constructor that sets Star.radiusY = radiusX and Star.magnitude = 0.
Definition: star-utils.hpp:55
decimal radiusX
Approximate horizontal radius of the bright area in pixels.
Definition: star-utils.hpp:63
int magnitude
A relative measure of magnitude of the star.
Definition: star-utils.hpp:70
Records that a certain Star (detected in the image) corresponds to a certain CatalogStar.
Definition: star-utils.hpp:78
decimal weight
A weight indicating the confidence of this idenification. Often just 1.
Definition: star-utils.hpp:97
bool operator==(const StarIdentifier &other) const
Definition: star-utils.hpp:87
int catalogIndex
An index into an array of CatalogStar objects.
Definition: star-utils.hpp:95
StarIdentifier(int starIndex, int catalogIndex, int weight)
Definition: star-utils.hpp:80
StarIdentifier(int starIndex, int catalogIndex)
Sets StarIdentifier.weight = 1.
Definition: star-utils.hpp:83
int starIndex
An index into an array of Star objects.
Definition: star-utils.hpp:93
Three dimensional vector with decimaling point components.
double decimal
Definition: decimal.hpp:11
#define DECIMAL(x)
Definition: decimal.hpp:21
LOST starting point.
std::vector< StarIdentifier > StarIdentifiers
Definition: star-utils.hpp:102
void SerializeCatalog(SerializeContext *ser, const Catalog &catalog, bool inclMagnitude, bool inclName)
Serialize the catalog to buffer.
Definition: star-utils.cpp:107
Catalog DeserializeCatalog(DeserializeContext *des, bool *inclMagnitudeReturn, bool *inclNameReturn)
Deserialize a catalog.
Definition: star-utils.cpp:123
decimal MagToBrightness(int mag)
returns some relative brightness measure, which is proportional to the total number of photons receiv...
Definition: star-utils.cpp:147
std::vector< Star > Stars
Definition: star-utils.hpp:101
Vec3 SphericalToSpatial(decimal ra, decimal de)
Convert from right ascension & declination to a 3d point on the unit sphere.
Catalog NarrowCatalog(const Catalog &catalog, int maxMagnitude, int maxStars, decimal minSeparation)
Remove unwanted stars from an unfiltered catalog.
Definition: star-utils.cpp:17
Catalog::const_iterator FindNamedStar(const Catalog &catalog, int name)
Return a pointer to the star with the given name, or NULL if not found.
Definition: star-utils.cpp:54
std::vector< CatalogStar > Catalog
Definition: star-utils.hpp:100
A two dimensional vector with decimaling point components.