The MASM Forum
Miscellaneous => Miscellaneous Projects => Topic started by: jj2007 on March 19, 2013, 11:58:22 AM
-
I am playing with two new macros that use a variant of the Horner scheme:
SetPoly3 My3Pts() ; use three XY pairs to get a0...a2
GetPoly3(AllPts()) ; fill an array using y=a0+a1*(x-x0)+a2*(x-x0)*(x-x1)
Work in progress. In the attached executable, the two outer points are fixed, the middle one moves with the mouse.
-
very cool :t
i remember, long ago, i needed something like this
now, i can't remember what it was for - lol
that was back in the DOS days
it seems to hang up under certain conditions - hard to describe
i am sure you are aware of it - as you say, work in progress
-
it seems to hang up under certain conditions - hard to describe
Usually you can unblock it by moving around the lower right corner.
Here is a variant that uses the three red points to define the bounding rectangle. The only difference is that now the other points can go outside the rect.
if 1 ; optional: use the "biggest" array to define a common range
ArrayPlot My3Pts(XY), 0, 0, MyMargins, SetRange ; the three red points define the range
else
ArrayPlot AllPts(XY), 0, 0, MyMargins, SetRange ; the big array defines the range
endif
-
Seeing your code would be nice indeed ;-)
it is an assembler forum, afterall :P
-
I somehow like the idea and looked up for an robust algorithm for getting polynomials through arbitrary points and found the method of divided differences (similar: hermite interpolation ).
An C implementation can be found here (http://people.sc.fsu.edu/~jburkardt/c_src/divdif/divdif.c) (functions: data_to_dif and dif_val).
In the attachment a example (sry, no source): with the left mouse button you can add and drag points, which are used for interpolation. With the right mouse button selected points are removed.
qWord
-
method of divided differences (similar: hermite interpolation )
Nice link :t
Reference:
Carl deBoor,
A Practical Guide to Splines,
Springer, 2001
The reference for my macros is Dubbel, Taschenbuch für den Maschinenbau (http://de.wikipedia.org/wiki/Taschenbuch_f%C3%BCr_den_Maschinenbau), Springer 19xx (can't find the book right now, but it must be before 1981).
If I find time over the weekend, I'll post a new edition of MasmBasic with the sources.
EDIT: Sources are online, see here (http://masm32.com/board/index.php?topic=94.msg17181#msg17181)