Instrument Neutral Distributed Interface INDI 2.2.5
HaltonSequence.h
Go to the documentation of this file.
1
12
13#pragma once
14
15#include <cmath>
16#include <utility>
17
18namespace INDI
19{
20namespace AlignmentSubsystem
21{
22
25{
26 public:
30 HaltonSequence(int baseX = 2, int baseY = 3) : m_baseX(baseX), m_baseY(baseY) {}
31
36 static double term(int i, int base)
37 {
38 double result = 0.0;
39 double f = 1.0;
40 while (i > 0)
41 {
42 f /= static_cast<double>(base);
43 result += (i % base) * f;
44 i /= base;
45 }
46 return result;
47 }
48
52 std::pair<double, double> getRaw(int n) const
53 {
54 return {term(n, m_baseX), term(n, m_baseY)};
55 }
56
58 double getX(int n) const
59 {
60 return term(n, m_baseX);
61 }
62
64 double getY(int n) const
65 {
66 return term(n, m_baseY);
67 }
68
69 private:
70 int m_baseX;
71 int m_baseY;
72};
73
74} // namespace AlignmentSubsystem
75} // namespace INDI
Generic 2-D Halton quasi-random generator.
double getY(int n) const
Get the n-th value of the individual Y dimension.
HaltonSequence(int baseX=2, int baseY=3)
Construct a generator with specified prime bases.
std::pair< double, double > getRaw(int n) const
Get the n-th 2-D point in the sequence.
static double term(int i, int base)
Compute the i-th raw Halton term in the given base.
double getX(int n) const
Get the n-th value of the individual X dimension.
Namespace to encapsulate INDI client, drivers, and mediator classes.