> ,___________________________,
> | ~~~~~~~~---------~~~~ |
> | |
> | |
> | |
> | |
> | |
> | |
> | _______ |
> |-~~ ~~~~~~-----___ |
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~'
>
> We need the coordinates of the rectangle: Rx, Ry, Rw, Rh:
>
> Rx = min(Ax, Bx);
> Ry = min(Ay, Dy);
> Rw = max(Cx, Dx) - Rx;
> Rh = max(By, Cy) - Ry;
>
> Also we need the width and height of the rectangle, it's obvious how to
> compute it.
Rw is the width an Rh is the height.
> The easiest way is to interpolate the curves with several linear segments,
> something like this:
>
> 2 3
> 1 *_____* 4
> A*-~~ ~~~~~~--*--___ 5
> ~~~*D
>
Make sure the segments have the same width (or x-distance), this will
help in finding the right segment
> The algorithm would work as follows: First, it finds the relative Tx
> coordinate in the range 0-1 (of course, all math should use fixed-point
> integer arithmetic, 16.16 precision should be quite enough for this):
>
> x = (Tx - Rx) / Rw
> y = (Ty - Ry) / Rh
>
> Now we find the segments on the top and bottom curves with the same X
> (the curve points must use fixed-point coordinates in the range 0-1
> as well):
>
> for (int top = 0; top_curve [top].x < x; top++) ;
> for (int bot = 0; bot_curve [bot].x < x; bot++) ;
segnum = x/segwidth? When segwidth is a power of two you can bitshift.
> Now find the respective Y on the top and bottom curves:
>
> top_y = (x - top_curve [top].x) * (top_curve [top + 1].y - top_curve [top].y)
> bot_y = (x - bot_curve [bot].x) * (bot_curve [bot + 1].y - bot_curve [bot].y)
>
> (I hope you see that there's a lot that could be precomputed here in advance).
> Now let's find the Y coordinate of the point in rectangle space (range 0-1):
>
> y = (y - bot_y) / (top_y - bot_y);
>
> Now find the X and Y coordinates of the T point in real coordinates:
>
> Mx = Rx + Rw * x;
> My = Ry + Rh * y;
>
> Ugh, okay, I hope nobody felt asleep due to my shitty English and math.
I had to draw the step to get the idea. It seems good. Maybe we can
offer the users a two step calibration: first trace the edges, compute
the arrays and then let the user do the 5 point calibration.
I haven't investigated this, but it seems to me wince uses a lower
ts-resolution than linux, maybe that's why CE can be calibrated this
easy.
regards,
Koen Kooi
Received on Tue May 04 2004 - 13:11:31 EDT
This archive was generated by hypermail 2.2.0 : Mon Jul 25 2005 - 17:19:27 EDT