A simple Spline
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
A simple Spline
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
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
- Attachments
-
- Simple Spline.zip
- (3.92 KiB) Downloaded 171 times
Last edited by micmac on Fri Jan 20, 2023 4:28 pm, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: A simple Spline
Could you please ex-spline what you want us to do with this?
Re: A simple Spline
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
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
Its up to your imagination.richmond62 wrote: ↑Fri Jan 20, 2023 2:31 pmCould you please ex-spline what you want us to do with this?
Mic
Re: A simple Spline
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
micMac.
That was probably it. Works fine now.
I miss Hermann.
Craig
That was probably it. Works fine now.
I miss Hermann.
Craig
Re: A simple Spline
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.
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
I know Stam
As I said it was in the simplest form for you to elaborate on...
Mic
As I said it was in the simplest form for you to elaborate on...
Mic
Re: A simple Spline
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
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"
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
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
And thanks Michael for digging this up.
Kind regards
Bernd
Re: A simple Spline
Always nice when you tune in Bernd!
Added you code
Added you code
- Attachments
-
- Simple Spline.zip
- (3.98 KiB) Downloaded 158 times
Re: A simple Spline
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
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