Cubic Spline? Anyone?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 970
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Cubic Spline? Anyone?

Post by trevix » Mon Aug 24, 2020 6:07 pm

Hi.
I have been using the graph widget but I would like to convert a scattered set of points (X,Y) to a smooth curved line (like in the attachment).
So, giving up the graph widget, I did some research and I realized that:
- my math sucks
- probably i need to do "cubic spline interpolation" (!?)

Somebody has done this already or is willing to share some simple math example?

Thanks
(I've seen the BezieCurve in the Rasberry section but I am not sure if is the correct example to study)
Attachments
Schermata 2020-08-24 alle 19.01.39.png
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9454
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cubic Spline? Anyone?

Post by richmond62 » Mon Aug 24, 2020 7:51 pm

https://en.wikiversity.org/wiki/Cubic_S ... polynomial.

Ooer: that only served to remind me that, at about 16, I got off the 'Maths Train.'

trevix
Posts: 970
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Cubic Spline? Anyone?

Post by trevix » Mon Aug 24, 2020 9:14 pm

Gasp!
Not very helpful to me.
I need some LC code
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9454
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cubic Spline? Anyone?

Post by richmond62 » Mon Aug 24, 2020 9:50 pm

Actually that Wikipedia page explains things in a comparatively comprehensible fashion.

stam
Posts: 2756
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Cubic Spline? Anyone?

Post by stam » Tue Nov 24, 2020 12:55 pm

richmond62 wrote:
Mon Aug 24, 2020 7:51 pm
https://en.wikiversity.org/wiki/Cubic_S ... polynomial.

Ooer: that only served to remind me that, at about 16, I got off the 'Maths Train.'
I like to think I'm OK at maths but that wikipedia page made my eyes water... :shock: :shock:


A cursory search found this: livecode-bezier-line-demo
Untested and don't know if it will help, but worth a look...
Last edited by stam on Wed Nov 25, 2020 3:05 pm, edited 1 time in total.

Klaus
Posts: 13865
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Cubic Spline? Anyone?

Post by Klaus » Tue Nov 24, 2020 4:19 pm

stam wrote:
Tue Nov 24, 2020 12:55 pm
I like to think I'm OK at maths but that wikipedia page made my eyes water... :shock: :shock:
I was alway weak at math, and yes, I immediately closed the page above when I saw it!
stam wrote:
Tue Nov 24, 2020 12:55 pm
A cursor search found this: livecode-bezier-line-demo
Untested and don't know if it will help, but worth a look...
Ah, one of Scott Rossis stacks, can't be wrong and will surely look gorgeous! :-)

opn
Posts: 5
Joined: Fri Jun 19, 2015 9:46 am

Re: Cubic Spline? Anyone?

Post by opn » Tue Jun 14, 2022 12:33 pm

I'm looking for that function to smooth the points of a curve graphic!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9454
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cubic Spline? Anyone?

Post by richmond62 » Tue Jun 14, 2022 2:27 pm

https://use-livecode.runrev.narkive.com ... aphic-oval

Frankly, I'm drunk, but I'll get back to this chestnut when I sober up.

And, oddly enough, through an alcoholic haze, the word 'interpolation' crops up.

AND, "Krishna on a bike", trying to send an SVG file of a boardgame to a Laser printer via some extremely wonky Chinglish
documentation at the moment, and/or generate "G Code" via an Inkscape extension to do the same, while thinking
about smoothing curves.
Last edited by richmond62 on Tue Jun 14, 2022 7:53 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9454
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Cubic Spline? Anyone?

Post by richmond62 » Tue Jun 14, 2022 3:14 pm

Well, I certainly had fun playing with this:

go url "http://tactilemedia.com/blog/bezier"

It is a very great sadness that Alejandro 'vanished'.

The thing that really rocked was that I had never come across a

Code: Select all

before mouseDown
handler before . . .

stam
Posts: 2756
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Cubic Spline? Anyone?

Post by stam » Tue Jun 14, 2022 5:40 pm

Everything on Scott Rossi's blog post is worth looking at.
I especially liked the translucent flashing stack: animated WindowShapes

http://tactilemedia.com/blog/2018/05/12 ... -the-past/

------------
edit: having had a closer look at the animated windowshapes stack again i must admit it's clever ;)
the main image is basically an animated PNG where each frame's binary data is stored in a custom prop of the base image and is just cycled through.
Simple but effective!

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”