summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-08-10 17:26:56 +0100
committerHenrik Rydberg <rydberg@euromail.se>2010-08-10 17:30:17 +0100
commit5abd33f31af910fe1cbdd270bbd2c1342799b576 (patch)
tree4c93efdcfdf1a6e6b7e18e5e7442d002e42a0005
parent212a4c23ffde2c5e220665f0a32cca534dc64ede (diff)
change rotation units to angles
Use angle units, such that a complete revolution corresponds to 2 pi. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--include/grail-types.h6
-rw-r--r--src/grail-gestures.c10
2 files changed, 8 insertions, 8 deletions
diff --git a/include/grail-types.h b/include/grail-types.h
index 9f7160d..83a653c 100644
--- a/include/grail-types.h
+++ b/include/grail-types.h
@@ -64,9 +64,9 @@
64#define GRAIL_PROP_PINCH_X2 5 /* bounding box x2 */ 64#define GRAIL_PROP_PINCH_X2 5 /* bounding box x2 */
65#define GRAIL_PROP_PINCH_Y2 6 /* bounding box y2 */ 65#define GRAIL_PROP_PINCH_Y2 6 /* bounding box y2 */
66 66
67#define GRAIL_PROP_ROTATE_DA 0 /* arc delta */ 67#define GRAIL_PROP_ROTATE_DA 0 /* angle delta */
68#define GRAIL_PROP_ROTATE_VA 1 /* arc velocity */ 68#define GRAIL_PROP_ROTATE_VA 1 /* angular velocity */
69#define GRAIL_PROP_ROTATE_A 2 /* arc */ 69#define GRAIL_PROP_ROTATE_A 2 /* angle */
70 70
71#define GRAIL_PROP_TAP_DT 0 /* tap time (ms) */ 71#define GRAIL_PROP_TAP_DT 0 /* tap time (ms) */
72#define GRAIL_PROP_TAP_X 1 /* horizontal position */ 72#define GRAIL_PROP_TAP_X 1 /* horizontal position */
diff --git a/src/grail-gestures.c b/src/grail-gestures.c
index 1d49765..be53cc0 100644
--- a/src/grail-gestures.c
+++ b/src/grail-gestures.c
@@ -69,7 +69,7 @@ static float compute_rotation(float x, float y, float r,
69 const struct touch_frame *frame) 69 const struct touch_frame *frame)
70{ 70{
71 int i, n = frame->nactive; 71 int i, n = frame->nactive;
72 float da = 0, da2 = 0; 72 float da = 0, darc2 = 0;
73 if (n < 2) 73 if (n < 2)
74 return da; 74 return da;
75 for (i = 0; i < n; i++) { 75 for (i = 0; i < n; i++) {
@@ -79,10 +79,10 @@ static float compute_rotation(float x, float y, float r,
79 float dy = t->prop[TP_POS_Y] - y; 79 float dy = t->prop[TP_POS_Y] - y;
80 float mx = t->prop[TP_POS_X] - ot->prop[TP_POS_X]; 80 float mx = t->prop[TP_POS_X] - ot->prop[TP_POS_X];
81 float my = t->prop[TP_POS_Y] - ot->prop[TP_POS_Y]; 81 float my = t->prop[TP_POS_Y] - ot->prop[TP_POS_Y];
82 da2 += dx * my - dy * mx; 82 darc2 += dx * my - dy * mx;
83 } 83 }
84 da2 /= n; 84 darc2 /= n;
85 da = da2 / r; 85 da = darc2 / (r * r);
86 return da; 86 return da;
87} 87}
88 88
@@ -150,7 +150,7 @@ void gru_init_motion(struct grail *ge)
150 D[FM_X] = max.x - min.x; 150 D[FM_X] = max.x - min.x;
151 D[FM_Y] = max.y - min.y; 151 D[FM_Y] = max.y - min.y;
152 D[FM_R] = sqrt(D[FM_X] * D[FM_X] + D[FM_Y] * D[FM_Y]); 152 D[FM_R] = sqrt(D[FM_X] * D[FM_X] + D[FM_Y] * D[FM_Y]);
153 D[FM_A] = D[FM_R]; 153 D[FM_A] = 2 * M_PI;
154 for (i = 0; i < DIM_FM; i++) { 154 for (i = 0; i < DIM_FM; i++) {
155 m->fm[i].fuzz = D[i] / FM_SN[i]; 155 m->fm[i].fuzz = D[i] / FM_SN[i];
156 m->fm[i].bar = D[i] / FM_BAR[i]; 156 m->fm[i].bar = D[i] / FM_BAR[i];