3 #include <eigen3/Eigen/Dense>
4 #include <eigen3/Eigen/Eigenvalues>
10 #define EPSILON DECIMAL(0.0001)
16 if (starIdentifiers.size() < 2) {
19 assert(stars.size() >= 2);
22 #ifdef LOST_FLOAT_MODE
31 Star bStar = stars[s.starIndex];
34 #ifdef LOST_FLOAT_MODE
42 bi << bStarSpatial.
x, bStarSpatial.
y, bStarSpatial.
z;
48 B += ri * bi.transpose() * s.weight;
52 #ifdef LOST_FLOAT_MODE
53 Eigen::Matrix3f S = B + B.transpose();
55 Eigen::Matrix3d S = B + B.transpose();
62 #ifdef LOST_FLOAT_MODE
73 #ifdef LOST_FLOAT_MODE
79 K << sigma, Z(0), Z(1), Z(2),
80 Z(0), S(0,0) - sigma, S(0,1), S(0,2),
81 Z(1), S(1,0), S(1,1) - sigma, S(1,2),
82 Z(2), S(2,0), S(2,1), S(2,2) - sigma;
86 #ifdef LOST_FLOAT_MODE
87 Eigen::EigenSolver<Eigen::Matrix4f> solver(K);
88 Eigen::Vector4cf values = solver.eigenvalues();
89 Eigen::Matrix4cf vectors = solver.eigenvectors();
91 Eigen::EigenSolver<Eigen::Matrix4d> solver(K);
92 Eigen::Vector4cd values = solver.eigenvalues();
93 Eigen::Matrix4cd vectors = solver.eigenvectors();
97 decimal maxEigenvalue = values(0).real();
98 for (
int i = 1; i < values.size(); i++) {
99 if (values(i).real() > maxEigenvalue) {
101 maxEigenvalue = values(i).real();
106 #ifdef LOST_FLOAT_MODE
107 Eigen::Vector4cf maxEigenvector = vectors.col(maxIndex);
109 Eigen::Vector4cd maxEigenvector = vectors.col(maxIndex);
117 maxEigenvector[1].real(),
118 maxEigenvector[2].real(),
119 maxEigenvector[3].real()));
138 if (starIds.size() < 2) {
141 assert(stars.size() >= 2);
146 b = starIds[starIds.size()/2];
151 catalog[b.catalogIndex].spatial);
179 }
while (abs(height) >=
EPSILON);
189 if (starIdentifiers.size() < 2) {
192 assert(stars.size() >= 2);
198 Mat3 B = {0, 0, 0, 0, 0, 0, 0, 0, 0};
200 Star bStar = stars[s.starIndex];
208 B = B + (rStarSpatial.
OuterProduct(bStarSpatial) * s.weight);
220 B.
At(1,2) - B.
At(2,1),
221 B.
At(2,0) - B.
At(0,2),
222 B.
At(0,1) - B.
At(1,0)
230 decimal c = delta + (Z * S * Z);
239 decimal gamma = (eig + sigma) * alpha - delta;
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.
Attitude Go(const Camera &, const Stars &, const Catalog &, const StarIdentifiers &)
Actually run the star-id algorithm.
3x3 vector with decimaling point components
Mat3 Inverse() const
Inverse of a matrix.
decimal Det() const
Determinant of a matrix.
Mat3 Transpose() const
Transpose of a matrix.
decimal Trace() const
Trace of a matrix.
decimal At(int i, int j) const
Access the i,j-th element of the matrix.
A quaternion is a common way to represent a 3d rotation.
Attitude Go(const Camera &, const Stars &, const Catalog &, const StarIdentifiers &)
Actually run the star-id algorithm.
A "centroid" detected in an image.
Vec2 position
The (x,y) pixel coordinates in the image (top left is 0,0)
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.
Attitude Go(const Camera &, const Stars &, const Catalog &, const StarIdentifiers &)
Actually run the star-id algorithm.
Three dimensional vector with decimaling point components.
Vec3 Normalize() const
Create a vector pointing in the same direction with magnitude 1.
decimal MagnitudeSq() const
The square of the magnitude.
Mat3 OuterProduct(const Vec3 &) const
The outer product of two vectors.
Vec3 CrossProduct(const Vec3 &) const
Usual vector cross product.
#define DECIMAL_POW(base, power)
std::vector< StarIdentifier > StarIdentifiers
std::vector< Star > Stars
decimal QuestEigenvalueEstimator(decimal guess, decimal a, decimal b, decimal c, decimal d, decimal s)
Approximates roots of a real function using the Newton-Raphson algorithm.
const Mat3 kIdentityMat3
3x3 identity matrix
decimal QuestCharPoly(decimal x, decimal a, decimal b, decimal c, decimal d, decimal s)
Characteristic polynomial of the quest K-matrix.
decimal QuestCharPolyPrime(decimal x, decimal a, decimal b, decimal c)
Derivitive of the characteristic polynomial of the quest K-matrix.
std::vector< CatalogStar > Catalog