Page 1 of 3

Curve smoothing

Posted: Wed Oct 09, 2024 11:00 am
by stevepoole
Hi Folks,
In my UFO_bas progam I used curve-smoothing code written in the late '80s. Interpolating curves is still a major maths research subject.

The original code was written for tracing contours on maps. A statistician asked me if it could be used with financial data ? Yes...!

The Demo has had one or two quirks improved, but I am still working to remove one case which causes 'sharp' points.

They are easy to trap, but not yet resolved completely. But the result is still better than most 'Bezier Spline' routines.

Curve precision can be ajusted on line 140 (prec=4 to 40). See its effects with dotss=4 on line 130 !

The code is long but fast, since the program steps far between the many conditional blocks, depending on how dots are positioned !
ContourDemo.zip
(4.2 KiB) Downloaded 154 times
Capture d’écran (575).png

Re: Curve smoothing

Posted: Thu Oct 10, 2024 6:33 pm
by qbits
Hi steve,

Looks cool!

QBITS

Re: Curve smoothing

Posted: Thu Oct 10, 2024 6:50 pm
by Cristian
nice!

Re: Curve smoothing

Posted: Mon Oct 14, 2024 9:58 am
by stevepoole
Hi Folks,
Curve smoothing has many applications, including statistics, encryption and decompression of waveforms, etc.

This program version eliminates former 'sharpish' apexes and straight lines, and caters for the terminating end-points.

A final version will allow you to load in your own data, (which is randomly generated for this demo).

Just UNZIP and LRUN or hit 'n' to repeat the paused output. You can alter the number of dots and the precision : see top of listing.

Have started fully commenting the code in REMarks, as there is a lot of it, mostly written in the late eighties. Regards, Steve.
ContourDemo2.zip
(4.51 KiB) Downloaded 143 times
Capture d’écran (578).png

Re: Curve smoothing

Posted: Mon Oct 14, 2024 11:45 am
by martyn_hill
Darn it, Steve!

How clever :-)

Re: Curve smoothing

Posted: Mon Oct 14, 2024 8:44 pm
by Cristian
An error occurs
error.jpg

Re: Curve smoothing

Posted: Mon Oct 14, 2024 9:26 pm
by stevepoole
Hi Cristian,

This error may be a name-table problem. What system are you using ?

The program has run for a week under QPC2, with randomised data, tested ok... Steve.
__________________

Re: Curve smoothing

Posted: Mon Oct 14, 2024 10:14 pm
by dilwyn
Running it on QPC2 I get the error

At line 1310:3 assignment can only be to a variable or array element

That statement is qx = xc-xd, the only thing I can think of is that QX is a clashing command name in a QLiberator toolkit extension?

Certainly, if I run t on a "clean" QPC2 (i.e. no extensions loaded), it works OK.

Re: Curve smoothing

Posted: Mon Oct 14, 2024 10:39 pm
by stevepoole
Hi Dilwyn,

Thanks for the feedback. Try changing the variable 'qx' to 'xq' on line 1310, and three times on line 1330. That should do it ?

_________________

Re: Curve smoothing

Posted: Mon Oct 14, 2024 10:59 pm
by stevepoole
Hi Cristian,

The error on your system stems from the variables 'ax' and 'ay' not being initialised : (Not a problem under QPC2).

Insert the following code : < 685 ax=t(a,x) : ay=t(a,y) > and all should be well....

When any more compatibility bugs are notified, I will issue a fixed version. Thanks for the feedback, Steve.

_________________