Page 1 of 1
A simple Spline
Posted: Fri Jan 20, 2023 2:21 pm
by micmac
A Natural Spline in its simplest form.
For you to elaborate on.
All math and coding credited to the late Herman [-hh].
Code taken from here:
http://forums.livecode.com/viewtopic.ph ... 87#p163787
Cleaned up and simplified by me.
Mic
Re: A simple Spline
Posted: Fri Jan 20, 2023 2:31 pm
by richmond62
Could you please ex-spline what you want us to do with this?
Re: A simple Spline
Posted: Fri Jan 20, 2023 3:41 pm
by dunbarx
micmac
I don't see how to manipulate the red "handles". These are typically the control points in adjusting the shape of a spline curve. Nothing seems to do anything.
Craig
Re: A simple Spline
Posted: Fri Jan 20, 2023 3:44 pm
by micmac
richmond62 wrote: ↑Fri Jan 20, 2023 2:31 pm
Could you please ex-spline what you want us to do with this?
Its up to your imagination.
Mic
Re: A simple Spline
Posted: Fri Jan 20, 2023 4:15 pm
by micmac
dunbarx wrote: ↑Fri Jan 20, 2023 3:41 pm
micmac
I don't see how to manipulate the red "handles". These are typically the control points in adjusting the shape of a spline curve. Nothing seems to do anything.
Craig
OK I see it
Its probably the Behaviors that do not carry over.
I changed the stack name just before I uploaded
I reUp
Re: A simple Spline
Posted: Fri Jan 20, 2023 4:23 pm
by micmac
RE-UP
Corrected behaviors
Re: A simple Spline
Posted: Fri Jan 20, 2023 6:29 pm
by dunbarx
micMac.
That was probably it. Works fine now.
I miss Hermann.
Craig
Re: A simple Spline
Posted: Sun Jan 22, 2023 12:22 am
by stam
That's really nice Mic, I'll have to spend some time digesting this as definitely have a use for something like this.
I did however very quickly run into a reproducible crash - if manipulating the red buttons I accidentally make the curve exceed the bounds of the card like this:
then for me it causes an immediate crash to the debugger:
Otherwise very nice, thank you....
S.
Re: A simple Spline
Posted: Sun Jan 22, 2023 10:19 am
by micmac
I know Stam
As I said it was in the simplest form for you to elaborate on...
Mic
Re: A simple Spline
Posted: Sun Jan 22, 2023 3:27 pm
by stam
micmac wrote: ↑Sun Jan 22, 2023 10:19 am
As I said it was in the simplest form for you to elaborate on...
Really this should be an IDE tool.
The code in the attached stack above is convoluted enough with its 1 or 2-letter variables and almost complete lack of comments/documentation that realistically I personally will probably not able to 'elaborate' on it further.
Maybe someone with actual time on their hands else can fix the code's issues (eg the crash described above, being able to change acuity of the spline angle without changing length the spline etc). I wouldn't mind the challenge of doing this myself but given my commitments that's sadly
completely unrealistic.
Or maybe LC will finally improve their line-drawing tools in the new IDE and offer a spline, who knows...
Re: A simple Spline
Posted: Mon Jan 23, 2023 11:05 pm
by bn
Hermann's code threw errors when a divide by zero occurred.
For me it does not throw any errors anymore when adding the line marked by " -- Added BN" to handler computeNaturalCoefficients of the script of button "naturalSpline"
Code: Select all
on computeNaturalCoefficients
put cpN into n
put empty into h; put empty into l; put empty into m; put empty into z; put empty into b
repeat with i=0 to n-1
put xs[i+1]-xs[i] into h[i]
if h[i] is 0 then put 1 into h[i] -- Added BN
end repeat
-- more code
This is just empirical... Not that I understand the code. (And yes Stam, I never liked these short hand variable names but then Hermann was a Mathematician and for him one letter variable names probably seemed natural)
And thanks Michael for digging this up.
Kind regards
Bernd
Re: A simple Spline
Posted: Tue Jan 24, 2023 2:48 pm
by micmac
Always nice when you tune in Bernd!
Added you code
Re: A simple Spline
Posted: Wed Jan 25, 2023 12:33 pm
by bn
Thanks Michael,
Here is a link to a stack that implements bezier curves by Scott Rossi.
http://tactilemedia.com/blog/2015/12/06 ... line-demo/
It is somewhat related to this topic.
Kind regards
Bernd