[From Bruce Abbott (950220.1540 EST)]
Bill Powers (950219.1017)
Bruce Abbott (950219.1445)
I wonder if you wrote the program in your post the way it was run.
p = vert/horiz;
e = p - ref; { ref = 1.0 initially }
h = h - k * (e*horiz);
As presented, p depends only on vert, because horiz is a constant! You
seem to have left out the dependence of horiz on handle. And I don't
know why you multiplied e by horiz.
What is presented above fits the model vertical line length to the actual
vertical line length, given the data written to disk, which consist only of
the horizontal and vertical line lengths. The horizontal line length is
being disturbed throughout the run, so it is most definitely NOT a constant
(unless you meant during one step in the computational loop). Also, Vert
depends on the handle, not Horiz, as you note below:
The data recorded are
horiz^[i] := 2 * (XLength + oldt);
vert^[i] := YLength + oldc;
Since the horizontal length is independent of the model we can leave it
as it is. But if the cursor position is numerically equal to the handle
position (the code says it is) we have to write the model this way:
p = (Ylength + c)/horiz
e = p - r
h = h - k*e
c = h;
Where Ylength = Maxy div 3 or 479/3 or 159.
O.K., so let's plug in some numbers. Say horiz = 200, vert = 150, and
r = 1.0. Then:
p = vert/horiz = 0.75
c = 150 - 159 = -9.
e = p - r = 0.75 - 1.00 = -0.25
If k = 1.0 then all error should be eliminated in one clock tick. Is it?
Let's see:
h = h - k*e = -9 - (1.0 * -0.25) = -9 + .75 = -8.75
vert = 159 + -8.75 = 150.25
p = vert/horiz = 150.25/200 = 0.75125
e = p - r = 0.75125 - 1.00 = -.25875
That doesn't seem to work. Let's start over at the point where we compute h
but using my formula:
h = h - k*(e * horiz) = -9 - (1.0 * (-0.25 * 200)) = -9 +50 = 41
vert = 159 + 41 = 200
p = vert/horiz = 200/200 = 1.0
e = p - r = 1.0 - 1.0 = 0
Now that's more like it. The only difference between this approach and my
original one is that I used h = vert rather than h = c, thus computing the
model's vertical line length directly rather than the mouse position and
eliminating the need to know about that constant of 159.
I asked Rick to post his code as a check because I was worried I'd made some
logical error in the computations. Given your response, Bill, I'm still
worried, but my way seems to work. Rick?
Regards,
Bruce