POV-Ray : Newsgroups : povray.binaries.scene-files : Making functions for natural cubic splines Server Time
24 Apr 2024 10:26:06 EDT (-0400)
  Making functions for natural cubic splines (Message 14 to 23 of 23)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Bald Eagle
Subject: Re: Making functions for natural cubic splines
Date: 13 Oct 2014 14:00:00
Message: <web.543c127f5b2bbe7b5e7df57c0@news.povray.org>
A bigger improvement would be if I actually attached the file.  :\


Post a reply to this message


Attachments:
Download 'cubicsplines.bas.txt' (5 KB)

From: Tor Olav Kristensen
Subject: Re: Making functions for natural cubic splines
Date: 14 Oct 2014 21:00:00
Message: <web.543dc63d5b2bbe7b7b9c043a0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> A bigger improvement would be if I actually attached the file.  :\

I've now modified that JustBasic file so that it makes a 2D plot of the X(T),
Y(T) and Z(T) splines.

--
Tor Olav
http://subcube.com


Post a reply to this message


Attachments:
Download 'natural_cubic_splines_04.bas.txt' (6 KB)

From: Bald Eagle
Subject: Re: Making functions for natural cubic splines
Date: 14 Oct 2014 23:30:00
Message: <web.543de9d05b2bbe7b5e7df57c0@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > A bigger improvement would be if I actually attached the file.  :\
>
> I've now modified that JustBasic file so that it makes a 2D plot of the X(T),
> Y(T) and Z(T) splines.

T.O.K. = "Quick study".  Nice work.

Yeah, that's cool.
I'm sure it would be a lot cooler if I understood what to do with that...

Unfortunately, when I tried to:

for p = 0 to N
    #grid, "size 5"
    #grid, "down"
    #grid, "color pink"
    #grid, "set "; XX(p); " "; YY(p)
    #grid, "up"
next p

in that space to see where the original (x,y) coordinates would be, that didn't
work out so hot.

This must be some "T"-space, or "affine"-something-or-other that has to get
mapped back into "x,y"-space, or something like that.
Yeah.  That sounds good.

I'm getting the feeling that I'm like the short lady who needed my help getting
the butter off the back of the top shelf of the fridge in the supermarket....

Do you guys have crayons and sock-puppets?


Post a reply to this message

From: Nevado
Subject: Re: Making functions for natural cubic splines
Date: 15 Oct 2014 00:20:02
Message: <web.543df5b35b2bbe7b6dce1a360@news.povray.org>
Sorry, went my own way with this, needing to build the code myself to understand
it. But I have something now that looks promising, using parametric functions
and solving with matrices.
I'm doing a little debugging on it now for the next couple of days.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Making functions for natural cubic splines
Date: 15 Oct 2014 04:00:01
Message: <web.543e27af5b2bbe7bb9f9ec750@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > "Bald Eagle" <cre### [at] netscapenet> wrote:
> > > A bigger improvement would be if I actually attached the file.  :\
> >
> > I've now modified that JustBasic file so that it makes a 2D plot of the X(T),
> > Y(T) and Z(T) splines.
>
> T.O.K. = "Quick study".  Nice work.
>
> Yeah, that's cool.
> I'm sure it would be a lot cooler if I understood what to do with that...
>
> Unfortunately, when I tried to:
>
> for p = 0 to N
>     #grid, "size 5"
>     #grid, "down"
>     #grid, "color pink"
>     #grid, "set "; XX(p); " "; YY(p)
>     #grid, "up"
> next p
>
> in that space to see where the original (x,y) coordinates would be, that didn't
> work out so hot.
>
> This must be some "T"-space, or "affine"-something-or-other that has to get
> mapped back into "x,y"-space, or something like that.
> Yeah.  That sounds good.
......

Hehe =)
Thank you

Use Abscissa(XX(p)), Ordinate(YY(p)) instead, like this:

#grid, "set "; Abscissa(XX(p)); " "; Ordinate(YY(p))

To show Origo, use this:

#grid, "set "; Abscissa(0); " "; Ordinate(0)

http://en.wikipedia.org/wiki/Abscissa

I didn't want to confuse further by introducing more Xs and Ys.

I can explain more later about the scaling and "mapping" that these two
functions do.

--
Tor Olav
http://subcube.com


Post a reply to this message

From: Bald Eagle
Subject: Re: Making functions for natural cubic splines
Date: 15 Oct 2014 10:05:00
Message: <web.543e7e995b2bbe7b5e7df57c0@news.povray.org>
I figured that there had to be a scaling to the screen relative to the range of
the point coordinates - I was just way too tired to "get it."

for p = 0 to N
    #grid, "size 5"
    #grid, "down"
    #grid, "color pink"
    #grid, "set "; Abscissa(XX(p), MinX, MaxX); " "; Ordinate(YY(p), MinY, MaxY)
    #grid, "up"
next p

Seems to work ok - except for the far right point, probably since the window
isn't full screen.  Multiplying ordinate and abscissa by 0.9 inside the function
scales that down a bit, and all 5 points are visible.

Now I just need to work out how to draw the right x,y curves in 2d and splice
out the parts between the endpoints, excluding the control points.  I'm guessing
studying the POV code that already graphs the curves might clue me in if I'm
alert enough to follow what's happening


Post a reply to this message

From: Bald Eagle
Subject: Re: Making functions for natural cubic splines
Date: 17 Oct 2014 11:40:00
Message: <web.544137ff5b2bbe7b5e7df57c0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

>      t
>
> is the time since the beginning of the segment.


Perhaps with your greater experience dealing with the structure of these things,
you could suggest how best I can "reverse engineer" a sphere_sweep to a spline.

It look like a regular spline has these t-values defined.

#declare MySpline =
spline {
  cubic_spline
    -.25, <0,0,-1>
    0.00, <1,0,0>
    0.25, <0,0,1>
    0.50, <-1,0,0>
    0.75, <0,0,-1>
    1.00, <1,0,0>
    1.25, <0,0,1>
    }

It seems that with a sphere sweep, the t-values must be constructed as part of
the spline calculation?  Can I access those t-values in some way to use my
sphere sweep data to generate a "regular" spline?
I'm looking to progress along a spline in a linear fashion - regularly spaced
intervals.

sphere_sweep {
 cubic_spline
 14,
 <-8.8750, 29.3750, 12>, 1.7500/2, // Control Point
 <-8.8750, 28.2500, 12>, 1.7500/2,
 <-8.8750, 27.1250, 12>, 1.2500/2,
 <-8.3750, 26.5000, 12>, 1.0000/2,
 <-8.7500, 25.6250, 12>, 0.7500/2,
 <-8.5313, 24.8438, 12>, 0.5625/2,
 <-8.0625, 24.1250, 12>, 0.5000/2,
 <-7.5000, 23.7500, 12>, 0.5000/2,
 <-6.7500, 23.6250, 12>, 0.5000/2,
 <-6.0000, 23.7500, 12>, 0.5000/2,
 <-5.4375, 24.0000, 12>, 0.5000/2,
 <-4.9375, 24.4375, 12>, 0.6250/2,
 <-4.4375, 25.3125, 12>, 1.1250/2,
 <-3.9375, 26.1875, 12>, 1.1250/2   //  Control Point
     tolerance 0.1
}

(What I'm trying to do at this point is "draw" between my sphere sweep and
another sphere sweep or spline to "fill-in" the space between the two.  Maybe
there's a better way that escapes me at the moment.)


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Making functions for natural cubic splines
Date: 18 Oct 2014 08:40:00
Message: <web.54425e955b2bbe7b7b9c043a0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
....
> I'm looking to progress along a spline in a linear fashion - regularly spaced
> intervals.
....
> (What I'm trying to do at this point is "draw" between my sphere sweep and
> another sphere sweep or spline to "fill-in" the space between the two.  Maybe
> there's a better way that escapes me at the moment.)

Did you see these two posts ?

Newsgroup: povray.binaries.images
From: Tor Olav Kristensen
Subject: Spacing of points along natural cubic splines
Date: 12th Dec 2010
http://news.povray.org/povray.binaries.images/thread/%3Cweb.4d04e35320256a0cc734aecd0%40news.povray.org%3E/

Newsgroup: povray.text.scene-files
From: Tor Olav Kristensen
Subject: Even spacing of points along natural cubic splines
Date: 12th Dec 2010
http://news.povray.org/povray.text.scene-files/thread/%3Cweb.4d04dadb31d78932c734aecd0%40news.povray.org%3E/

I suggest that you make your own sphere sweeps with these functions (with
"connected" spheres, cylinders and cones if the spheres radii varies).
That way there's no need to "recover" the t-values afterwards.

--
Tor Olav
http://subcube.com


Post a reply to this message

From: Bald Eagle
Subject: Re: Making functions for natural cubic splines
Date: 18 Oct 2014 11:10:00
Message: <web.544281a35b2bbe7b5e7df57c0@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:

I did not look at those - too many things going on all at the same time, lol.

I did manage to work it out fairly closely - but this ought to help get it
working a lot better without having to plot so many cylinders.
I thought blobbing them all together would help - but I noticed some strange
behaviour.  threshold 0 gave me a web-like fill, and then raising it to 0.1 gave
me a much fuller effect.

I still need to work out a method for the upholstery "tufting", if I decide that
would add enough to be worth the effort.  :)

> I suggest that you make your own sphere sweeps with these functions (with
> "connected" spheres, cylinders and cones if the spheres radii varies).
> That way there's no need to "recover" the t-values afterwards.

So, make a third array with the diameters, and interpolate the intermediate
values...

That could be an interesting thing to experiment with - I suppose there's no
limit to the number of additional arrays - for color, texture, normals, etc.


Post a reply to this message

From: clipka
Subject: Re: Making functions for natural cubic splines
Date: 22 Oct 2014 11:12:24
Message: <5447c958$1@news.povray.org>
Am 18.10.2014 17:05, schrieb Bald Eagle:

> That could be an interesting thing to experiment with - I suppose there's no
> limit to the number of additional arrays - for color, texture, normals, etc.

Whatever fits inside your computer's memory.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.