[dasher: 1/11] Tidy EyetrackerFilter co-ordinate transform.
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 1/11] Tidy EyetrackerFilter co-ordinate transform.
- Date: Sat, 31 Jul 2010 14:07:16 +0000 (UTC)
commit f7d29ada06b9f61ade31226e2cfa8bbc18f086f6
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Wed Jun 23 11:41:20 2010 +0100
Tidy EyetrackerFilter co-ordinate transform.
I assert this is equivalent to what was there before!
Src/DasherCore/EyetrackerFilter.cpp | 48 +++++++---------------------------
Src/DasherCore/EyetrackerFilter.h | 2 +-
2 files changed, 11 insertions(+), 39 deletions(-)
---
diff --git a/Src/DasherCore/EyetrackerFilter.cpp b/Src/DasherCore/EyetrackerFilter.cpp
index 8cd6ce5..43018ff 100644
--- a/Src/DasherCore/EyetrackerFilter.cpp
+++ b/Src/DasherCore/EyetrackerFilter.cpp
@@ -30,57 +30,29 @@ bool CEyetrackerFilter::GetSettings(SModuleSettings **pSettings, int *iCount) {
};
void CEyetrackerFilter::ApplyTransform(myint &iDasherX, myint &iDasherY) {
- double disty=(myint)GetLongParameter(LP_OY)-iDasherY;
- myint x( iDasherX );
- myint dasherOX=(myint)GetLongParameter(LP_OX);
-
- // if( iDasherX < dasherOX ) {
-
- //cout << "dasherOX: " << dasherOX << endl;
+ // Y co-ordinate...
myint dasherOY=(myint)GetLongParameter(LP_OY);
+ double double_y = ((iDasherY-dasherOY)/(double)(dasherOY) ); // Fraction above the crosshair
+ static const double repulsionparameter=0.5;
+ iDasherY = myint(dasherOY * (1.0 + double_y + (double_y*double_y*double_y * repulsionparameter )));
- // X co-ordinate changes.
- double double_x = (x/dasherOX); // Fraction of way over to crosshair
- double double_y = -((iDasherY-dasherOY)/(double)(dasherOY) ); // Fraction above the crosshair
-
- // FIXME - I have *no* idea how this is supposed to work - someone else fix it and comment the code please!
-
- double xmax_y = xmax(double_x, double_y);
-
- if(double_x < xmax_y) {
- double_x = xmax_y;
- }
-
- // std::cout << xmax_y << std::endl;
-
- x = myint(dasherOX*double_x);
-
- // Finished x-coord changes.
-
- double repulsionparameter=0.5;
- iDasherY = myint(dasherOY - (1.0+ double_y*double_y* repulsionparameter ) * disty);
-
- if( iDasherX < x )
- iDasherX = x;
+ // X co-ordinate...
+ iDasherX = max(iDasherX,myint(GetLongParameter(LP_OX) * xmax(double_y)));
}
-double CEyetrackerFilter::xmax(double x, double y) {
+double CEyetrackerFilter::xmax(double y) {
// DJCM -- define a function xmax(y) thus:
// xmax(y) = a*[exp(b*y*y)-1]
// then: if(x<xmax(y) [if the mouse is to the RIGHT of the line xmax(y)]
// set x=xmax(y). But set xmax=c if(xmax>c).
// I would set a=1, b=1, c=16, to start with.
- int a = 1, b = 1, c = 100;
- double xmax = a * (exp(b * y * y) - 1);
+ static const int a = 1, b = 1;
+ static const double c = 100;
+ return min(c,a * (exp(b * y * y) - 1));
//cout << "xmax = " << xmax << endl;
-
- if(xmax > c)
- xmax = c;
-
- return xmax;
}
void CEyetrackerFilter::ApplyAutoCalibration(myint &iDasherX, myint &iDasherY, bool bUpdate) {
diff --git a/Src/DasherCore/EyetrackerFilter.h b/Src/DasherCore/EyetrackerFilter.h
index b1e14f4..3e07828 100644
--- a/Src/DasherCore/EyetrackerFilter.h
+++ b/Src/DasherCore/EyetrackerFilter.h
@@ -15,7 +15,7 @@ class CEyetrackerFilter : public CDefaultFilter {
private:
virtual void ApplyAutoCalibration(myint &iDasherX, myint &iDasherY, bool bUpdate);
virtual void ApplyTransform(myint &iDasherX, myint &iDasherY);
- double xmax(double x, double y);
+ double xmax(double y);
myint m_iYAutoOffset;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]