forked from opengazer/OpenGazer
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHeadCompensation.cpp
More file actions
34 lines (28 loc) · 817 Bytes
/
HeadCompensation.cpp
File metadata and controls
34 lines (28 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "LeastSquares.h"
class HeadCompensation {
LeastSquares xparams, yparams;
const HeadTracker &head;
double xa0, xa1, xa2, ya0, ya1, ya2;
int samples;
public:
HeadCompensation(HeadTracker const& head):
xparams(3), yparams(3), head(head),
xa0(0.0), xa1(0.0), xa2(0.0),
ya0(0.0), ya1(0.0), ya2(0.0), samples(0)
{}
void addCorrection(Point correction) {
xparams.addSample(head.rotx, head.roty, 1.0, correction.x);
yparams.addSample(head.rotx, head.roty, 1.0, correction.y);
samples++;
}
void updateFactors(void) {
if (samples > 0) {
xparams.solve(xa0, xa1, xa2);
yparams.solve(ya0, ya1, ya2);
}
}
Point estimateCorrection(void) {
return Point(xa0 * head.rotx + xa1 * head.roty + xa2,
ya0 * head.rotx + ya1 * head.roty + ya2);
}
};