13#include <unordered_map>
26static constexpr int kNumEdgeRatios =
28using HashCode = std::array<int, kNumEdgeRatios>;
34static std::set<HashCode> GenerateCandidateHashCodes(
const std::vector<decimal>& edgeRatios,
38 std::array<std::pair<int, int>, kNumEdgeRatios> binRanges;
39 size_t totalCombinations = 1;
40 for (
int i = 0; i < kNumEdgeRatios; i++) {
41 int lo = std::max(0,
int((edgeRatios[i] - searchRange) * numBins));
42 int hi = std::min(numBins,
int((edgeRatios[i] + searchRange) * numBins) + 1);
43 binRanges[i] = {lo, hi};
44 totalCombinations *= (hi - lo);
48 std::set<HashCode> hashCodes;
50 for (
int i = 0; i < kNumEdgeRatios; i++)
51 currentBins[i] = binRanges[i].first;
53 for (
size_t iter = 0; iter < totalCombinations; iter++) {
56 std::sort(sortedBins.begin(), sortedBins.end());
57 hashCodes.insert(sortedBins);
59 for (
int binDim = kNumEdgeRatios - 1; binDim >= 0; binDim--) {
60 currentBins[binDim]++;
61 if (currentBins[binDim] < binRanges[binDim].second)
break;
62 currentBins[binDim] = binRanges[binDim].first;
69static std::vector<int> SortByCentroidRadius(
const std::vector<int>& indices,
70 const std::vector<Vec3>& vecs) {
71 Vec3 centroid{0, 0, 0};
72 for (
const Vec3& v : vecs)
73 centroid = centroid + v;
74 centroid = centroid * (
DECIMAL(1.0) / vecs.size());
76 std::vector<int> order(indices.size());
77 std::iota(order.begin(), order.end(), 0);
78 std::sort(order.begin(), order.end(), [&](
int a,
int b) {
79 return (vecs[a] - centroid).MagnitudeSq() < (vecs[b] - centroid).MagnitudeSq();
82 std::vector<int> result;
84 result.push_back(indices[i]);
91static StarIdentifiers PairByCentroidRadius(
const std::vector<int>& centroidIndices,
92 const std::vector<Vec3>& observedStarVecs,
93 const std::vector<int>& catalogInds,
94 const std::vector<Vec3>& catalogStarVecs) {
95 std::vector<int> sortedCentroids = SortByCentroidRadius(centroidIndices, observedStarVecs);
96 std::vector<int> sortedCatalog = SortByCentroidRadius(catalogInds, catalogStarVecs);
99 for (
int i = 0; i < (int)sortedCentroids.size(); i++) {
100 result.push_back(
StarIdentifier(sortedCentroids[i], sortedCatalog[i]));
109static StarIdentifiers PairByTriadPermutation(
const std::vector<int>& centroidIndices,
110 const std::vector<Vec3>& observedStarVecs,
111 const std::vector<int>& catalogInds,
112 const std::vector<Vec3>& catalogStarVecs,
116 const size_t n = observedStarVecs.size();
117 std::vector<int> perm(n);
118 for (
size_t i = 0; i < n; i++)
121 decimal bestResidual = std::numeric_limits<decimal>::max();
122 std::vector<int> bestPerm = perm;
129 for (
size_t i = 0; i < n; i++) {
130 ids.push_back(
StarIdentifier(centroidIndices[i], catalogInds[perm[i]]));
134 Attitude att = estimator.Go(camera, stars, catalog, ids);
135 if (!att.IsKnown())
continue;
141 for (
size_t i = 0; i < n; i++) {
142 Vec3 rotated = q.Rotate(observedStarVecs[i]);
144 decimal dot = rotated * expectedVec;
149 if (residual < bestResidual) {
150 bestResidual = residual;
153 }
while (std::next_permutation(perm.begin(), perm.end()));
156 for (
size_t i = 0; i < n; i++) {
157 result.push_back(
StarIdentifier(centroidIndices[i], catalogInds[bestPerm[i]]));
165 const Camera& camera)
const {
167 const unsigned char* databaseBuffer =
169 if (databaseBuffer ==
nullptr) {
170 std::cerr <<
"Could not get to Tetra database" << std::endl;
181 std::vector<int> centroidIndices(stars.size());
182 std::iota(centroidIndices.begin(), centroidIndices.end(), 0);
185 std::sort(centroidIndices.begin(), centroidIndices.end(), [&stars](
int a,
int b) {
186 return stars[a].magnitude > stars[b].magnitude;
191 while (combos.
next()) {
192 const std::vector<int>& comboIndices = combos.
indices();
197 int centroidInd = centroidIndices[comboIndices[i]];
198 selectedCentroidIndices[i] = centroidInd;
205 [&](
int i) ->
const Vec3& {
return observedStarVecs[i]; },
208 if (!angleAcceptable) {
213 observedStarVecs.size(), [&](
int i) ->
const Vec3& { return observedStarVecs[i]; });
215 std::set<HashCode> hashCodes =
216 GenerateCandidateHashCodes(observedEdgeRatios, patternSearchRange_, numEdgeRatioBins);
218 for (
const HashCode& code : hashCodes) {
223 if (matches.empty())
continue;
227 std::vector<int> catalogInds;
228 std::vector<Vec3> catalogStarVecs;
230 std::vector<int> candidateInds;
231 std::vector<Vec3> candidateVecs;
232 for (
int star : matchRow) {
234 candidateInds.push_back(catalogInd);
235 candidateVecs.push_back(catalog[catalogInd].spatial);
239 candidateVecs.size(), [&](
int i) ->
const Vec3& { return candidateVecs[i]; });
241 bool ratiosMatch =
true;
242 for (
size_t i = 0; i < catalogEdgeRatios.size(); i++) {
243 if (std::abs(catalogEdgeRatios[i] - observedEdgeRatios[i]) >
244 patternMatchTolerance_) {
251 if (numVerified == 0) {
252 catalogInds = std::move(candidateInds);
253 catalogStarVecs = std::move(candidateVecs);
256 if (numVerified > 1)
break;
261 if (numVerified == 1) {
263 return PairByTriadPermutation(selectedCentroidIndices,
271 return PairByCentroidRadius(
272 selectedCentroidIndices, observedStarVecs, catalogInds, catalogStarVecs);
278 std::cerr <<
"TETRA FAIL: nothing could be matched" << std::endl;
286 unsigned int randomSeed = 123456;
287 for (
int i = 0; i < (int)stars.size(); i++) {
288 result.push_back(
StarIdentifier(i, rand_r(&randomSeed) % catalog.size()));
295 const unsigned char *database,
const Stars &stars,
const Catalog &catalog,
const Camera &camera)
const {
300 if (databaseBuffer == NULL) {
306 for (
int i = 0; i < (int)stars.size(); i++) {
307 std::vector<int16_t> votes(catalog.size(), 0);
309 for (
int j = 0; j < (int)stars.size(); j++) {
312 std::vector<bool> votedInPair(catalog.size(),
false);
316 decimal lowerBoundRange = greatCircleDistance - tolerance;
317 decimal upperBoundRange = greatCircleDistance + tolerance;
318 const int16_t *upperBoundSearch;
320 lowerBoundRange, upperBoundRange, &upperBoundSearch);
322 for (
const int16_t *k = lowerBoundSearch; k != upperBoundSearch; k++) {
323 if ((k - lowerBoundSearch) % 2 == 0) {
324 decimal actualAngle =
AngleUnit(catalog[*k].spatial, catalog[*(k+1)].spatial);
325 assert(actualAngle <= greatCircleDistance + tolerance * 2);
326 assert(actualAngle >= greatCircleDistance - tolerance * 2);
328 if (!votedInPair[*k] ||
true) {
334 votedInPair[*k] =
true;
341 int16_t maxVotes = votes[0];
343 for (
int v = 1; v < (int)votes.size(); v++) {
344 if (votes[v] > maxVotes) {
366 identified.push_back(newStar);
373 std::vector<int16_t> verificationVotes(identified.size(), 0);
374 for (
int i = 0; i < (int)identified.size(); i++) {
376 for (
int j = i + 1; j < (int)identified.size(); j++) {
378 CatalogStar first = catalog[identified[i].catalogIndex];
379 CatalogStar second = catalog[identified[j].catalogIndex];
382 Star firstIdentified = stars[identified[i].starIndex];
383 Star secondIdentified = stars[identified[j].starIndex];
391 verificationVotes[i]++;
392 verificationVotes[j]++;
397 int maxVotes = verificationVotes.size() > 0 ? verificationVotes[0] : 0;
398 for (
int v = 1; v < (int)verificationVotes.size(); v++) {
399 if (verificationVotes[v] > maxVotes) {
400 maxVotes = verificationVotes[v];
408 int thresholdVotes = maxVotes * 3 / 4;
409 printf(
"Verification threshold: %d\n", thresholdVotes);
410 for (
int i = 0; i < (int)verificationVotes.size(); i++) {
411 if (verificationVotes[i] > thresholdVotes) {
412 verified.push_back(identified[i]);
441 : pairs(NULL), end(NULL) { };
450 : pairs(pairs), end(end), involving(involving) {
452 assert((end-pairs)%2 == 0);
453 ForwardUntilInvolving();
466 ForwardUntilInvolving();
488 const int16_t *pairs;
494 void ForwardUntilInvolving() {
495 while (pairs != end) {
496 if (pairs[0] == involving) {
500 if (pairs[1] == involving) {
510 std::vector<int16_t> result;
512 result.push_back(*it);
534static void PairDistanceQueryToMap(
const int16_t *pairs,
const int16_t *end,
size_t catalogSize,
FlatPairMap *m) {
535 m->
offsets.assign(catalogSize + 1, 0);
536 for (
const int16_t *p = pairs; p != end; p += 2) {
537 assert(p[0] >= 0 && (
size_t)p[0] < catalogSize);
538 assert(p[1] >= 0 && (
size_t)p[1] < catalogSize);
543 for (
auto last = m->
offsets.begin(), next = last+1; next != m->
offsets.end(); last++, next++) {
546 m->
values.resize(end - pairs);
548 for (
const int16_t *p = pairs; p != end; p += 2) {
567 for (
const auto &otherPair : identifiedStarsInRange) {
568 decimal curAngleFrom90 = VerticalAnglesToAngleFrom90(otherPair.first, angleFromVertical);
576 identifiedStarsInRange.emplace_back(angleFromVertical, starId);
586 std::vector<IRUnidentifiedCentroid *> *centroids,
const Star &star,
const Camera &camera,
594 std::vector<std::vector<IRUnidentifiedCentroid *>::iterator> result;
595 for (
auto it = centroids->begin(); it != centroids->end(); ++it) {
597 decimal angleCos = ourSpatial * theirSpatial;
598 if (angleCos >= minCos && angleCos <= maxCos) {
599 result.push_back(it);
637 std::vector<IRUnidentifiedCentroid *> *aboveThresholdCentroids,
638 std::vector<IRUnidentifiedCentroid *> *belowThresholdCentroids,
643 std::vector<int16_t> nowBelowThreshold;
646 (*centroidIt)->AddIdentifiedStar(starId, stars);
647 if ((*centroidIt)->bestAngleFrom90 <= angleFrom90Threshold) {
648 belowThresholdCentroids->push_back(*centroidIt);
649 nowBelowThreshold.push_back((*centroidIt)->index);
653 aboveThresholdCentroids->erase(std::remove_if(aboveThresholdCentroids->begin(), aboveThresholdCentroids->end(),
655 return std::find(nowBelowThreshold.begin(), nowBelowThreshold.end(), centroid->index) != nowBelowThreshold.end();
656 }), aboveThresholdCentroids->end());
672 int16_t catalogIndex1, int16_t catalogIndex2,
676 const int16_t *query1End;
677 const int16_t *query1 = db.
FindPairsExact(catalog, distance1-tolerance, distance1+tolerance, &query1End);
679 const Vec3 &spatial1 = catalog[catalogIndex1].spatial;
680 const Vec3 &spatial2 = catalog[catalogIndex2].spatial;
685 std::vector<int16_t> result;
691 Vec3 candidateSpatial = catalog[*candidateIt].spatial;
696 if (!(angle2 >= distance2-tolerance && angle2 <= distance2+tolerance)) {
701 decimal spectralTorch = cross * candidateSpatial;
704 if (spectralTorch <= 0) {
709 result.push_back(*candidateIt);
716 std::vector<IRUnidentifiedCentroid *> *belowThresholdCentroids) {
717 if (!belowThresholdCentroids->empty()) {
718 auto result = belowThresholdCentroids->back();
719 belowThresholdCentroids->pop_back();
724 auto bestAboveThreshold = std::min_element(aboveThresholdCentroids->begin(), aboveThresholdCentroids->end(),
726 return a->bestAngleFrom90 < b->bestAngleFrom90;
730 if (bestAboveThreshold != aboveThresholdCentroids->end() && (*bestAboveThreshold)->bestAngleFrom90 < 10) {
731 auto result = *bestAboveThreshold;
732 aboveThresholdCentroids->erase(bestAboveThreshold);
753#ifdef LOST_DEBUG_PERFORMANCE
754 auto startTimestamp = std::chrono::steady_clock::now();
757 std::vector<IRUnidentifiedCentroid> allUnidentifiedCentroids;
758 std::vector<IRUnidentifiedCentroid *> aboveThresholdUnidentifiedCentroids;
759 std::vector<IRUnidentifiedCentroid *> belowThresholdUnidentifiedCentroids;
760 allUnidentifiedCentroids.reserve(stars.size());
761 for (
size_t i = 0; i < stars.size(); i++) {
765 aboveThresholdUnidentifiedCentroids.reserve(allUnidentifiedCentroids.size());
766 for (
size_t i = 0; i < allUnidentifiedCentroids.size(); i++) {
768 if (std::find_if(identifiers->begin(), identifiers->end(),
769 [&allUnidentifiedCentroids, i](
const StarIdentifier &identifier) {
770 return identifier.starIndex == allUnidentifiedCentroids[i].index;
771 }) == identifiers->end()) {
773 aboveThresholdUnidentifiedCentroids.push_back(&allUnidentifiedCentroids[i]);
785 for (
const auto &starId : *identifiers) {
787 &aboveThresholdUnidentifiedCentroids, &belowThresholdUnidentifiedCentroids,
793 int numExtraIdentifiedStars = 0;
796 while (!belowThresholdUnidentifiedCentroids.empty() || !aboveThresholdUnidentifiedCentroids.empty()) {
799 if (nextUnidentifiedCentroid == NULL) {
813 std::vector<int16_t> candidates =
826 if (candidates.size() != 1) {
827 if (candidates.size() > 1) {
828 std::cerr <<
"WARNING: Multiple catalog stars matched during identify remaining stars. This should be rare." << std::endl;
832 identifiers->emplace_back(nextUnidentifiedCentroid->
index, candidates[0]);
836 &aboveThresholdUnidentifiedCentroids, &belowThresholdUnidentifiedCentroids,
842 ++numExtraIdentifiedStars;
847 assert(belowThresholdUnidentifiedCentroids.empty());
849#ifdef LOST_DEBUG_PERFORMANCE
850 auto endTimestamp = std::chrono::steady_clock::now();
851 std::cout <<
"IdentifyRemainingStarsPairDistance took " << std::chrono::duration_cast<std::chrono::microseconds>(endTimestamp - startTimestamp).count() <<
"us" << std::endl;
854 return numExtraIdentifiedStars;
858 const unsigned char *database,
const Stars &stars,
const Catalog &catalog,
const Camera &camera)
const {
863 if (databaseBuffer == NULL || stars.size() < 4) {
864 std::cerr <<
"Not enough stars, or database missing." << std::endl;
878 int numStars = (int)stars.size();
880 int across = floor(sqrt(numStars))*2;
881 int halfwayAcross = floor(sqrt(numStars)/2);
882 long totalIterations = 0;
886 int jMax = numStars - 3;
887 for (
int jIter = 0; jIter < jMax; jIter++) {
888 int dj = 1+(jIter+halfwayAcross)%jMax;
890 int kMax = numStars-dj-2;
891 for (
int kIter = 0; kIter < kMax; kIter++) {
892 int dk = 1+(kIter+across)%kMax;
894 int rMax = numStars-dj-dk-1;
895 for (
int rIter = 0; rIter < rMax; rIter++) {
896 int dr = 1+(rIter+halfwayAcross)%rMax;
898 int iMax = numStars-dj-dk-dr-1;
899 for (
int iIter = 0; iIter <= iMax; iIter++) {
900 int i = (iIter + iMax/2)%(iMax+1);
903 if (++totalIterations > cutoff) {
904 std::cerr <<
"Cutoff reached." << std::endl;
912 assert(i != j && j != k && k != r && i != k && i != r && j != r);
928 decimal expectedMismatches = expectedMismatchesConstant
931 / std::max(std::max(iSinInner, jSinInner), kSinInner);
933 if (expectedMismatches > maxMismatchProbability) {
934 std::cout <<
"skip: mismatch prob." << std::endl;
941 bool spectralTorch = iSpatial.
CrossProduct(jSpatial)*kSpatial > 0;
955#define _CHECK_DISTANCE(_dist) \
956 if (_dist < vectorDatabase.MinDistance() + tolerance \
957 || _dist > vectorDatabase.MaxDistance() - tolerance) \
964#undef _CHECK_DISTANCE
966 const int16_t *ijEnd, *ikEnd, *irEnd;
967 const int16_t *
const ijQuery = vectorDatabase.
FindPairsLiberal(ijDist - tolerance, ijDist + tolerance, &ijEnd);
968 const int16_t *
const ikQuery = vectorDatabase.
FindPairsLiberal(ikDist - tolerance, ikDist + tolerance, &ikEnd);
969 const int16_t *
const irQuery = vectorDatabase.
FindPairsLiberal(irDist - tolerance, irDist + tolerance, &irEnd);
972 if (ijQuery == ijEnd || ikQuery == ikEnd || irQuery == irEnd)
975 PairDistanceQueryToMap(ikQuery, ikEnd, catalog.size(), &ikMap);
976 PairDistanceQueryToMap(irQuery, irEnd, catalog.size(), &irMap);
978 int iMatch = -1, jMatch = -1, kMatch = -1, rMatch = -1;
979 for (
const int16_t *iCandidateQuery = ijQuery; iCandidateQuery != ijEnd; iCandidateQuery++) {
980 int iCandidate = *iCandidateQuery;
982 int jCandidate = (iCandidateQuery - ijQuery) % 2 == 0
984 : iCandidateQuery[-1];
986 assert(iCandidate >= 0 && iCandidate < (
int)catalog.size());
987 assert(jCandidate >= 0 && jCandidate < (
int)catalog.size());
989 const Vec3 &iCandidateSpatial = catalog[iCandidate].spatial;
990 const Vec3 &jCandidateSpatial = catalog[jCandidate].spatial;
994 for (int32_t kIdx = ikMap.
offsets[iCandidate]; kIdx < ikMap.
offsets[iCandidate+1]; kIdx++) {
995 int kCandidate = ikMap.
values[kIdx];
996 Vec3 kCandidateSpatial = catalog[kCandidate].spatial;
997 bool candidateSpectralTorch = ijCandidateCross*kCandidateSpatial > 0;
999 if (candidateSpectralTorch != spectralTorch) {
1005 if (jkCandidateDist < jkDist - tolerance || jkCandidateDist > jkDist + tolerance) {
1012 for (int32_t rIdx = irMap.
offsets[iCandidate]; rIdx < irMap.
offsets[iCandidate+1]; rIdx++) {
1013 int rCandidate = irMap.
values[rIdx];
1014 const Vec3 &rCandidateSpatial = catalog[rCandidate].spatial;
1017 if (jrCandidateDist < jrDist - tolerance || jrCandidateDist > jrDist + tolerance) {
1020 krCandidateDist =
AngleUnit(kCandidateSpatial, rCandidateSpatial);
1021 if (krCandidateDist < krDist - tolerance || krCandidateDist > krDist + tolerance) {
1028 iMatch = iCandidate;
1029 jMatch = jCandidate;
1030 kMatch = kCandidate;
1031 rMatch = rCandidate;
1035 std::cerr <<
"Pyramid not unique, skipping..." << std::endl;
1036 goto sensorContinue;
1045 std::cout.precision(6);
1046 std::cout <<
"Matched unique pyramid!" << std::endl <<
"Expected mismatches: " << std::scientific << expectedMismatches << std::endl << std::fixed;
1053 printf(
"Identified an additional %d stars.\n", numAdditionallyIdentified);
1054 assert(numAdditionallyIdentified == (
int)identified.size()-4);
1065 std::cerr <<
"Tried all pyramids; none matched." << std::endl;
The attitude (orientation) of a spacecraft.
A full description of a camera. Enough information to reconstruct the camera matrix and then some.
Vec3 CameraToSpatial(const Vec2 &) const
Gives a point in 3d space that could correspond to the given vector, using the same coordinate system...
A star from the Bright Star Catalog.
Vec3 spatial
The point on the unit sphere where the star lies.
const std::vector< int > & indices() const
StarIdentifiers Go(const unsigned char *database, const Stars &, const Catalog &, const Camera &) const
Actualy perform the star idenification. This is the "main" function for StarIdAlgorithm.
StarIdentifiers Go(const unsigned char *database, const Stars &, const Catalog &, const Camera &) const
Actualy perform the star idenification. This is the "main" function for StarIdAlgorithm.
unidentified centroid used in IdentifyRemainingStarsPairDistance The "angles" through here are "trian...
const Star * star
Index into list of all centroids.
StarIdentifier bestStar1
For the pair of other centroids forming the triangular angle closest to 90 degrees,...
void AddIdentifiedStar(const StarIdentifier &starId, const Stars &stars)
When a centroid within range of this centroid is identified, call this function.
StarIdentifier bestStar2
One star corresponding to bestAngleFrom90.
int16_t index
The other star corresponding to bestAngleFrom90.
const unsigned char * SubDatabasePointer(int32_t magicValue) const
MultiDatabase memory layout:
Given a list of star pairs, finds all those pairs which involve a certain star.
PairDistanceInvolvingIterator(const int16_t *pairs, const int16_t *end, int16_t involving)
The main constructor.
PairDistanceInvolvingIterator & operator++()
Move to the next matching pair.
int16_t operator*() const
Access the curent pair.
bool HasValue()
Whether the iterator is currently on a value. (false if iteration is complete).
PairDistanceInvolvingIterator()
Create a "past-the-end" iterator.
A database storing distances between pairs of stars.
decimal MinDistance() const
Lower bound on stored star pair distances.
static const int32_t kMagicValue
Magic value to use when storing inside a MultiDatabase.
const int16_t * FindPairsExact(const Catalog &, decimal min, decimal max, const int16_t **end) const
const int16_t * FindPairsLiberal(decimal min, decimal max, const int16_t **end) const
Return at least all the star pairs whose inter-star distance is between min and max.
decimal MaxDistance() const
Upper bound on stored star pair distances.
StarIdentifiers Go(const unsigned char *database, const Stars &, const Catalog &, const Camera &) const
Actualy perform the star idenification. This is the "main" function for StarIdAlgorithm.
A quaternion is a common way to represent a 3d rotation.
Quaternion Conjugate() const
Effectively computes a quaternion representing the inverse rotation of the original.
Records that a certain Star (detected in the image) corresponds to a certain CatalogStar.
int catalogIndex
An index into an array of CatalogStar objects.
int starIndex
An index into an array of Star objects.
A "centroid" detected in an image.
Vec2 position
The (x,y) pixel coordinates in the image (top left is 0,0).
A database storing Tetra star patterns.
uint16_t CatalogIndex(int tetraCatalogInd) const
std::vector< TetraPattern > GetPatternMatches(size_t index) const
static const int32_t kMagicValue
Magic value to use when storing inside a MultiDatabase.
uint64_t PatternTableSize() const
int NumEdgeRatioBins() const
StarIdentifiers Go(const unsigned char *database, const Stars ¢roids, const Catalog &catalog, const Camera &) const
Actualy perform the star idenification. This is the "main" function for StarIdAlgorithm.
A fast attitude estimator which only takes into account information from two stars.
Three dimensional vector with decimaling point components.
Vec3 Normalize() const
Create a vector pointing in the same direction with magnitude 1.
Vec3 CrossProduct(const Vec3 &) const
Usual vector cross product.
#define DECIMAL_POW(base, power)
#define DECIMAL_ATAN2(x, y)
bool AllPairsWithinFov(int numStars, SpatialAccessor spatial, decimal cosMaxFov)
std::vector< std::vector< IRUnidentifiedCentroid * >::iterator > FindUnidentifiedCentroidsInRange(std::vector< IRUnidentifiedCentroid * > *centroids, const Star &star, const Camera &camera, decimal minDistance, decimal maxDistance)
Return all the unidentified centroids within the requested distance bounds from star.
const decimal kAngleFrom90SoftThreshold
std::vector< StarIdentifier > StarIdentifiers
IRUnidentifiedCentroid * SelectNextUnidentifiedCentroid(std::vector< IRUnidentifiedCentroid * > *aboveThresholdCentroids, std::vector< IRUnidentifiedCentroid * > *belowThresholdCentroids)
size_t TetraFindPatternIndex(const int *patternEdgeRatios, size_t numRatios, int numEdgeRatioBins, size_t tableSize)
std::array< int, kNumEdgeRatios > HashCode
std::vector< Star > Stars
decimal AngleUnit(const Vec3 &vec1, const Vec3 &vec2)
Calculate the inner angle, in radians, between two /unit/ vectors.
decimal DegToRad(decimal deg)
decimal Angle(const Vec3 &vec1, const Vec3 &vec2)
Calculate the inner angle, in radians, between two vectors.
std::vector< decimal > TetraEdgeRatios(int numStars, SpatialAccessor spatial)
std::vector< int16_t > ConsumeInvolvingIterator(PairDistanceInvolvingIterator it)
int IdentifyRemainingStarsPairDistance(StarIdentifiers *, const Stars &, const PairDistanceKVectorDatabase &, const Catalog &, const Camera &, decimal tolerance)
Given some identified stars, attempt to identify the rest.
decimal DecimalModulo(decimal x, decimal mod)
Given a decimal, find it "modulo" another decimal, in the true mathematical sense (not remainder).
std::vector< int16_t > IdentifyThirdStar(const PairDistanceKVectorDatabase &db, const Catalog &catalog, int16_t catalogIndex1, int16_t catalogIndex2, decimal distance1, decimal distance2, decimal tolerance)
Given two already-identified centroids, and the distance from each to an as-yet unidentified third ce...
std::array< uint16_t, TetraConstants::numPatternStars > TetraPattern
std::vector< CatalogStar > Catalog
void AddToAllUnidentifiedCentroids(const StarIdentifier &starId, const Stars &stars, std::vector< IRUnidentifiedCentroid * > *aboveThresholdCentroids, std::vector< IRUnidentifiedCentroid * > *belowThresholdCentroids, decimal minDistance, decimal maxDistance, decimal angleFrom90Threshold, const Camera &camera)
Given a list of unidentified centroids not yet at the soft threshold, and a list of unidentified cent...
#define _CHECK_DISTANCE(_dist)
Given the result of a pair-distance kvector query, build a table of stars to other stars that appeare...
std::vector< int16_t > values
std::vector< int32_t > offsets
static constexpr int numPatternStars
A two dimensional vector with decimaling point components.