FOUND
Loading...
Searching...
No Matches
found::IterativeSphericalDistanceDeterminationAlgorithm Class Reference

The IterativeSphericalDistanceDeterminationAlgorithm is a variation of the SphericalDistanceDeterminationAlgorithm algorithm in that it runs it repeatedly to use all the points given to it. More...

#include <distance.hpp>

Inheritance diagram for found::IterativeSphericalDistanceDeterminationAlgorithm:
Collaboration diagram for found::IterativeSphericalDistanceDeterminationAlgorithm:

Public Member Functions

 IterativeSphericalDistanceDeterminationAlgorithm (decimal radius, Camera &&cam, size_t minimumIterations, decimal distanceRatio, decimal discriminatorRatio, int pdfOrder, int radiusLossOrder)
 Creates a IterativeSphericalDistanceDeterminationAlgorithm.
 
 ~IterativeSphericalDistanceDeterminationAlgorithm ()=default
 
PositionVector Run (const Points &p) override
 Obtains the position of the planet relative to the camera.
 
- Public Member Functions inherited from found::SphericalDistanceDeterminationAlgorithm
 SphericalDistanceDeterminationAlgorithm (decimal radius, Camera &&cam)
 Creates a SphericalDeterminationAlgorithm, which deduces the Position vector of a sattelite from Earth by modeling Earth as a sphere.
 
 ~SphericalDistanceDeterminationAlgorithm ()
 
PositionVector Run (const Points &p) override
 Obtains the position of the planet relative to the camera.
 
- Public Member Functions inherited from found::DistanceDeterminationAlgorithm
 DistanceDeterminationAlgorithm ()=default
 
virtual ~DistanceDeterminationAlgorithm ()
 
- Public Member Functions inherited from found::Stage< Points, PositionVector >
 Stage ()=default
 Constructs a new Stage.
 
virtual ~Stage ()=default
 Destroys this.
 
void DoAction () override
 Executes Run (with a stored input and storing the output)
 
PointsGetResource ()
 Returns the stored input of this.
 
PositionVector *& GetProduct ()
 Returns the stored output of this.
 

Private Member Functions

decimal GenerateLoss (PositionVector &position, decimal targetDistanceSq, decimal targetRadiusSq, std::unique_ptr< Vec3[]> &projectedPoints, size_t size)
 Generates a loss on a position vector.
 
void Shuffle (size_t size, size_t n, std::unique_ptr< size_t[]> &indicies)
 Shuffles the indexes into triplets, attempting to create triplets whose indicies are far from each other.
 
uint64_t Pow (uint64_t base, uint64_t power)
 Performs exponentiation for uint64_t.
 

Private Attributes

size_t minimumIterations_
 The minimum number of iterations to use.
 
decimal distanceRatioSq_
 The maximum distance ratio to accept.
 
decimal discriminatorRatio_
 The maximum loss ratio to accept.
 
uint64_t pdfOrder_
 The Shuffle randomization order.
 
uint64_t radiusLossOrder_
 The Loss Radius error order.
 

Additional Inherited Members

- Protected Member Functions inherited from found::SphericalDistanceDeterminationAlgorithm
Vec3 getCenter (Vec3 *spats)
 Returns the center of earth as a 3d Vector.
 
PreciseDecimal getRadius (Vec3 *spats, Vec3 center)
 Returns the radius of the calculated "earth" (normalized)
 
PreciseDecimal getDistance (PreciseDecimal r, PreciseDecimal c)
 Returns the scaled distance from earth.
 
- Protected Attributes inherited from found::SphericalDistanceDeterminationAlgorithm
Camera cam_
 cam_ field instance describes the camera settings used for the photo taken
 
decimal radius_
 radius_ field instance describes the defined radius of earth.
 
- Protected Attributes inherited from found::Stage< Points, PositionVector >
Points resource
 The stored input for this.
 
PositionVectorproduct
 The pointer to the stored output for this.
 

Detailed Description

The IterativeSphericalDistanceDeterminationAlgorithm is a variation of the SphericalDistanceDeterminationAlgorithm algorithm in that it runs it repeatedly to use all the points given to it.

It uses

  • selective randomization of Points, using a even polynomial distributions to prioritize points farther from selected points within triplets
  • loss criterion to evaluate each guess
  • softmax activation to figure out the plausibility of each guess
Note
Testing data on test/common/assets/example_earth1.png:

SDDA -> (1.0456e+07, -67903.8, -972.935) m

  • Distance Error: 0.752384891562%
  • Angle Error: 1339.6805912772 arcseconds
  • Execution Time: < 1 sec

ISDDA(100000, 0.8, INF, Quadratic Radius Loss AND Randomization) -> (1.0384e+07, -12571.3, -1057.05) m

  • Distance Error: 0.0565676042517%
  • Angle Error: 250.59497104116 arcseconds
  • Execution Time: 11 sec

ISDDA(100000, 0.8, INF, Quartic Radius Loss OR Randomization) -> (1.03781e+07, -11536.7, -927.331) m

  • Distance Error: 0.000294332681557%
  • Angle Error: 230.031583013 arcseconds
  • Execution Time: 11 sec

In optimized mode (-O3), all algorithms are less than 1 second.

Constructor & Destructor Documentation

◆ IterativeSphericalDistanceDeterminationAlgorithm()

found::IterativeSphericalDistanceDeterminationAlgorithm::IterativeSphericalDistanceDeterminationAlgorithm ( decimal  radius,
Camera &&  cam,
size_t  minimumIterations,
decimal  distanceRatio,
decimal  discriminatorRatio,
int  pdfOrder,
int  radiusLossOrder 
)

Creates a IterativeSphericalDistanceDeterminationAlgorithm.

Parameters
radiusThe radius of Earth
camThe camera used to capture the picture of Earth
minimumIterationsThe minimum number of iterations to perform
distanceRatioThe maximum distance error between the evaluated and reference positions to be considered "the same" distance
discriminatorRatioThe maximum ratio between the evaluated and reference loss to accept for data
pdfOrderThe Shuffle Randomization Distribution Order
radiusLossOrderThe Loss Radius Error Order
Note
Setting distanceRatio to DECIMAL_INF will exclude distance loss from loss calculations
Setting discriminatorRatio to DECIMAL_INF will include all generated points in the final point
Postcondition
If pdfOrder or radiusLossOrder less than 2, they will be made 2. Then if they are odd, they will be incremented

◆ ~IterativeSphericalDistanceDeterminationAlgorithm()

found::IterativeSphericalDistanceDeterminationAlgorithm::~IterativeSphericalDistanceDeterminationAlgorithm ( )
default

Member Function Documentation

◆ GenerateLoss()

decimal found::IterativeSphericalDistanceDeterminationAlgorithm::GenerateLoss ( PositionVector position,
decimal  targetDistanceSq,
decimal  targetRadiusSq,
std::unique_ptr< Vec3[]> &  projectedPoints,
size_t  size 
)
private

Generates a loss on a position vector.

Parameters
positionThe vector to evaluate
targetDistanceSqThe target distance squared of the position
targetRadiusSqThe target "radius" squared
projectedPointsThe projected points to evaluate against
sizeThe size of the projected points
Returns
The loss of position
Precondition
targetRadiusSq is not the true radius, but rather the distance obtained between the radius vector and a circle point when projected onto the unit sphere (normalized). It still functions the same way.

◆ Pow()

uint64_t found::IterativeSphericalDistanceDeterminationAlgorithm::Pow ( uint64_t  base,
uint64_t  power 
)
inlineprivate

Performs exponentiation for uint64_t.

Parameters
baseThe base
powerThe power

Return base ^ power

◆ Run()

PositionVector found::IterativeSphericalDistanceDeterminationAlgorithm::Run ( const Points p)
overridevirtual

Obtains the position of the planet relative to the camera.

Parameters
pThe points on the edge of Earth (in the image taken by the camera given to this)
Returns
PositionVector The position vector of the Earth relative to the camera
Precondition
p must refer to points taken by the camera that was passed to this
p is radially sorted, i.e. if we define the centroid of the points as P, for any three consecutive points A B and C, angle APB is less than angle APC
Postcondition
If p.size() < 3, then the result is exactly the zero vector
Note
If minimumIterations (from constructor) is less than the size of p, then it will increase the number of iterations to cover all of p

Implements found::Stage< Points, PositionVector >.

◆ Shuffle()

void found::IterativeSphericalDistanceDeterminationAlgorithm::Shuffle ( size_t  size,
size_t  n,
std::unique_ptr< size_t[]> &  indicies 
)
private

Shuffles the indexes into triplets, attempting to create triplets whose indicies are far from each other.

Parameters
sizeThe size of indicies, or how many indicies to generate
nThe end of the range to generate indicies for
indiciesThe array to write into
Precondition
Any precondition from this->Run
size > 0 && size % 3 == 0
Postcondition
for any i, 0 <= indicies[i] < n
Note
This algorithm uses a even polynomial distribution to prioritize points far away from a given index. We like that because it helps deal with noise. To exaggerate the difference in probability between points, you can use a function that grows much faster by changing the macro PDF which is defined within. Make sure the distribution function though is zero where you need it to be (i.e. At points already generated within a triplet so that you do not draw those points again)
The assumption of p from this->Run(p) being in polar order is quite important in this algorithm. Should that not be true, instead of using index differences in our polynomial distribution, we'd need to instead use the distance between the pixels corresponding to those indicies. This is not a terrible change in terms of code, but is more compuationally complex

Member Data Documentation

◆ discriminatorRatio_

decimal found::IterativeSphericalDistanceDeterminationAlgorithm::discriminatorRatio_
private

The maximum loss ratio to accept.

◆ distanceRatioSq_

decimal found::IterativeSphericalDistanceDeterminationAlgorithm::distanceRatioSq_
private

The maximum distance ratio to accept.

◆ minimumIterations_

size_t found::IterativeSphericalDistanceDeterminationAlgorithm::minimumIterations_
private

The minimum number of iterations to use.

◆ pdfOrder_

uint64_t found::IterativeSphericalDistanceDeterminationAlgorithm::pdfOrder_
private

The Shuffle randomization order.

◆ radiusLossOrder_

uint64_t found::IterativeSphericalDistanceDeterminationAlgorithm::radiusLossOrder_
private

The Loss Radius error order.


The documentation for this class was generated from the following files: