Curve smoothing

Anything QL Software or Programming Related.
stevepoole
Aurora
Posts: 888
Joined: Mon Nov 24, 2014 2:03 pm

Curve smoothing

Post 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 140 times
Capture d’écran (575).png


qbits
Gold Card
Posts: 251
Joined: Sun Dec 11, 2016 3:32 pm

Re: Curve smoothing

Post by qbits »

Hi steve,

Looks cool!

QBITS


User avatar
Cristian
QL Wafer Drive
Posts: 1024
Joined: Mon Feb 16, 2015 1:40 pm
Location: Veneto

Re: Curve smoothing

Post by Cristian »

nice!


stevepoole
Aurora
Posts: 888
Joined: Mon Nov 24, 2014 2:03 pm

Re: Curve smoothing

Post 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 131 times
Capture d’écran (578).png


martyn_hill
QL Wafer Drive
Posts: 1066
Joined: Sat Oct 25, 2014 9:53 am

Re: Curve smoothing

Post by martyn_hill »

Darn it, Steve!

How clever :-)


User avatar
Cristian
QL Wafer Drive
Posts: 1024
Joined: Mon Feb 16, 2015 1:40 pm
Location: Veneto

Re: Curve smoothing

Post by Cristian »

An error occurs
error.jpg


stevepoole
Aurora
Posts: 888
Joined: Mon Nov 24, 2014 2:03 pm

Re: Curve smoothing

Post 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.
__________________


User avatar
dilwyn
Mr QL
Posts: 3057
Joined: Wed Dec 01, 2010 10:39 pm

Re: Curve smoothing

Post 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.


stevepoole
Aurora
Posts: 888
Joined: Mon Nov 24, 2014 2:03 pm

Re: Curve smoothing

Post 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 ?

_________________


stevepoole
Aurora
Posts: 888
Joined: Mon Nov 24, 2014 2:03 pm

Re: Curve smoothing

Post 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.

_________________


Post Reply