Changes

Jump to navigation Jump to search
no edit summary
Line 65: Line 65:     
The threads for this built from [https://discourse.zynthian.org/search?q=x%20axis THe x axis threads]
 
The threads for this built from [https://discourse.zynthian.org/search?q=x%20axis THe x axis threads]
 +
 +
Hal80 explained it in proper terms... on this thread.
 +
https://discourse.zynthian.org/t/cant-solve-wrong-touch-coordinates-on-a-3-5-screen/4111/18
 +
 +
Hi, well, it’s just my gut feeling that comes from being a physicist :wink:
 +
Let me just briefly explain. It’s about so called affine projections (you can google it) which are used to map a point or rather a vector (which defines that point by two coordinate numbers in space, i.e. in x-y-plane) to a new position.
 +
Now, these 9 numbers which are written in a single row in the config file, actually make up a matrix which connects the output vector (new point, the point where we want the touch point to be) with the input vector (original point, the point where touch is recorded now) by means of matrix multiplication which in turn is composed of matrices for offset (translation), rotation and scaling. We need scaling and offset here.
 +
 +
In our special case, and according to the nomenclature given here https://wiki.archlinux.org/index.php/Calibrating_Touchscreen we can actually assign a meaning to these numbers.
 +
We have the matrix
 +
 +
[ c0 0  c1 ]
 +
[ 0  c2 c3 ]
 +
[ 0  0  1  ]
 +
which is equivalent to c0 0 c1 0 c2 c3 0 0 1 in our config file
 +
 +
where
 +
 +
c0 defines scale factor along x (horizontal) axis,
 +
c2 defines scale factor along y (vertical) axis,
 +
c1 defines x offset
 +
c3 defines y offset.
 +
All these numbers are defined relative to total width and total height according to the above link and this is why the new numbers should be close to 1. For example, introducing an offset to the right by 10 % of the total width (and c1 = 1) would result in the new c1 being 1.1. The nice thing about these matrix operations is that they do not only affect a single point in the x-y plane but all points that are thrown at it. You have to imagine it like pushing a sheet of paper around on a table (i.e. offset, translation), or like pulling on a stretchy piece of cloth on one end while the other end is fixed (i.e. scaling).
 +
 +
Just one remark about the minus signs - they come from the matrix operations for flipping and rotating the axes. As they appear in steps of 90 degrees these numbers are 1 or -1 or 0. It comes from the sin or cos function of the angle of rotation which yields 1, 0, -1 at multiples of 90 degrees but could also give any number inbetween at other angles. Which we don’t want :wink:
 +
 +
Now the only thing I’m uncertain about is, where is actually the corner (0,0).
 +
Is it centered at (screen_witdh / 2, screen_height/2) or is it at screen pixel (0,0) (would that be upper left corner?) or does it have it’s own reference frame…
584

edits

Navigation menu