POV-Ray : Newsgroups : povray.general : Cubic spline question Server Time
6 Aug 2024 19:28:55 EDT (-0400)
  Cubic spline question (Message 1 to 10 of 17)  
Goto Latest 10 Messages Next 7 Messages >>>
From: Rune
Subject: Cubic spline question
Date: 15 Feb 2002 17:22:36
Message: <3c6d8a2c@news.povray.org>
I'm getting confused by cubic splines.

Doesn't cubic splines work that way that any point on the spline is
dependent on exactly four control points, no more, no less? At least that's
the impression I get from the POV-Ray documentation, and when using cubic
splines in prisms it works exactly that way indeed.

But the cubic spline used in the spline feature in POV-Ray 3.5 works
completely differently. It seems that there any point on the spline is
dependent on all the control points, or at least much more than four as far
as I can see. The code below illustrates it (POV-Ray 3.5 beta 11).

So, can anyone enlighten me?

camera {location 6*y look_at 0 translate 3*x}
light_source {1000*y, color 1}
plane {y, 0 pigment {checker color rgb 1.0, color rgb 0.9}}
#declare Spline =
spline {
   cubic_spline
   0, 0*x+30*z,
   1, 1*x,
   2, 2*x,
   3, 3*x,
   4, 4*x,
   5, 5*x,
   6, 6*x,
}
#declare C = 0;
#while (C<=240)
   #declare V = C/40;
   #declare Color = <0,0,1>;
   #if (V=int(V)) #declare Color = <1,0,0>; #end
   sphere {Spline(V), 0.03+Color.x/50 pigment {color Color}}
   #declare C = C+1;
#end

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Jan 20)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: James Tonkin
Subject: Re: Cubic spline question
Date: 16 Feb 2002 00:53:58
Message: <3c6df3f6$1@news.povray.org>
>But the cubic spline used in the spline feature in POV-Ray 3.5 works
>completely differently. It seems that there any point on the spline is
>dependent on all the control points, or at least much more than four as far
>as I can see. The code below illustrates it (POV-Ray 3.5 beta 11).

Well, I don't have a copy of Povray handy to fire up and play with,
but as I understand it, the spline of any *segment* depends on exactly
4 points.  But splines can have more than 1 segment.

So with the points 0-6 in your example, you'd have the following
segments:

Segment 0:  exists between points 1 and 2, defined by points 0, 1, 2, 3
Segment 1:  exists between points 2 and 3, defined by points 1, 2, 3, 4
        2:                        3     4                    2, 3, 4, 5
        3:                        4     5                    3, 4, 5, 6

Jamie


Post a reply to this message

From: Mark Wagner
Subject: Re: Cubic spline question
Date: 16 Feb 2002 01:01:25
Message: <3c6df5b5@news.povray.org>
Rune wrote in message <3c6d8a2c@news.povray.org>...
>I'm getting confused by cubic splines.
>
>Doesn't cubic splines work that way that any point on the spline is
>dependent on exactly four control points, no more, no less? At least that's
>the impression I get from the POV-Ray documentation, and when using cubic
>splines in prisms it works exactly that way indeed.
>
>But the cubic spline used in the spline feature in POV-Ray 3.5 works
>completely differently. It seems that there any point on the spline is
>dependent on all the control points, or at least much more than four as far
>as I can see. The code below illustrates it (POV-Ray 3.5 beta 11).

I tried using the four control point method for pure splines, but that
resulted in sharp turns at the control points.  The "all control points"
method gives a spline that is smooth along its entire length (essential for
those applications that require computing the second derivative of the
spline).

--
Mark


Post a reply to this message

From: Rune
Subject: Re: Cubic spline question
Date: 16 Feb 2002 05:07:42
Message: <3c6e2f6e@news.povray.org>
"Mark Wagner" wrote:
> I tried using the four control point method for pure splines,
> but that resulted in sharp turns at the control points.

Funny, I've never had that problem and the splines in prisms don't have it
either.

> The "all control points" method gives a spline that is
> smooth along its entire length (essential for those
> applications that require computing the second
> derivative of the spline).

That's probably a fine spline, but is it a cubic spline or a completely
different type? To have different spline types go under the same name seem
like a very bad thing to do. Is it official POV-Team policy to do that?

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Jan 20)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Hugo
Subject: Re: Cubic spline question
Date: 16 Feb 2002 05:54:51
Message: <3c6e3a7b$1@news.povray.org>
> That's probably a fine spline, but is it a cubic spline or a completely
> different type?

I asked some spline questions a while ago because I think, Pov spline { }
behaves in unexpected ways that are hard to control. By reading Chris
Colefax's spline toturial I found that "cubic splines" are a broad class of
spline types. None of them seems to completely resemble the Pov spline { }
but I don't know for sure.. Someone told me, Pov is using "natural cubic
splines".. That's all I can tell.. With all respect to the Pov-team, I think
Colefax has done a better job, but it's alright for a beginning.


Hugo


Post a reply to this message

From: Rune
Subject: Re: Cubic spline question
Date: 16 Feb 2002 06:23:19
Message: <3c6e4127@news.povray.org>
"Hugo" wrote:
> By reading Chris Colefax's spline toturial I found that
> "cubic splines" are a broad class of spline types.

But AFAIK all of them use four control points per segment (because they're
cubic).

> Someone told me, Pov is using "natural cubic splines"..
> That's all I can tell..

I think that all splines in POV-Ray that go under the name "cubic spline"
should be identical, that being in prisms, spline{} or anything else. The
way it currently is seems very inconsistent and IMO strange.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Jan 20)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Mark Wagner
Subject: Re: Cubic spline question
Date: 17 Feb 2002 01:56:17
Message: <3c6f5411@news.povray.org>
Rune wrote in message <3c6e2f6e@news.povray.org>...
>"Mark Wagner" wrote:
>> The "all control points" method gives a spline that is
>> smooth along its entire length (essential for those
>> applications that require computing the second
>> derivative of the spline).
>
>That's probably a fine spline, but is it a cubic spline or a completely
>different type? To have different spline types go under the same name seem
>like a very bad thing to do. Is it official POV-Team policy to do that?

I am getting quite tired of repeatedly having to defend my decision on how
cubic splines work.  Rune, for the record, this is the third time I have
explained this to you.  This is the last time I will say this.  For the
record, here is what I have to say on the matter:

Cubic splines are a *very* *broad* *class* of splines.  The type I have
chosen to code in the spline{} functionality of POV-Ray are the natural
cubic splines.

From _Numerical Mathematics and Computing, Fourth Edition_, by Ward Cheney
and David Kincaid, a natural cubic spline is one where:

1) The function is constructed from a number of cubic polynomial pieces
2) The function is continuous
3) The first derivative of the function is continuous
4) The second derivative of the function is continuous
5) The function passes through all control points
6) The second derivative of the function is zero at the first and last
control points

For cubic splines in general, the first four conditions hold.

_Applied Numerical Methods_, by Brice Carnahan, H. A. Luther, and James
Wilkes agrees with these definitions.

These are the two textbooks I used in developing the cubic splines used in
the spline{} code.

From my experiments with producing a cubic spline by fitting a cubic
polynomial to each set of four control points, the resulting curve is
continuous and passes through all control points, but does not have
continuous first or second derivatives, and so is not a cubic spline of any
sort.  Rune, if you'll look at the image you attached to the post "Yet
another spline bug", posted on 8/29/01 in the povray.pre-beta.binaries
group, you'll see what happens when you produce a curve by this method.
From looking at the code for the prism object, it appears that this is the
method used by that object.

Rune, if you want a different behavior for cubic splines, please code it
yourself.

--
Mark


Post a reply to this message

From: Kari Kivisalo
Subject: Re: Cubic spline question
Date: 17 Feb 2002 03:04:19
Message: <3C6F644A.5E797131@engineer.com>
Mark Wagner wrote:

> 1) The function is constructed from a number of cubic polynomial pieces
> 2) The function is continuous
> 3) The first derivative of the function is continuous
> 4) The second derivative of the function is continuous
> 5) The function passes through all control points
> 6) The second derivative of the function is zero at the first and last
> control points

I can verify that cubic_spline in beta 11 meets these specifications.
Differences between splines through random 3D point sets produced by spline{}
and my lspline3 macro are too small to be noticed.


_____________
Kari Kivisalo


Post a reply to this message

From: Rune
Subject: Re: Cubic spline question
Date: 17 Feb 2002 03:56:46
Message: <3c6f704e@news.povray.org>
"Mark Wagner" wrote:
> I am getting quite tired of repeatedly having to
> defend my decision on how cubic splines work.
> Rune, for the record, this is the third time I
> have explained this to you.

I didn't know that, because the way the cubic splines have been worked have
been changing many times.

I acknowledge that I there's many things in this issue I don't know, so
that's why I asked. Ok, so the splines in the spline{} are indeed cubic
splines, just a different type than the splines used in prisms, which are
also labeled cubic splines.

> Rune, if you'll look at the image you attached to the post
> "Yet another spline bug", posted on 8/29/01 in the
> povray.pre-beta.binaries group, you'll see what happens
> when you produce a curve by this method. From looking at
> the code for the prism object, it appears that this is the
> method used by that object.

Sorry, but the sharp corners in the image I posted on 8/29/01 in the
povray.pre-beta.binaries group were caused by a buggy implementation rather
than the spline type itself. FYI prisms do not have such sharp corners.

Here are the problems I have with the current situation:

Cubic splines are a broad class of spline types, yet in both prisms and
spline{} it means a very specific spline. This wouldn't matter so much if it
was the same one in all features of POV-Ray, but to have the word
cubic_spline mean different things in different context is very inconsistent
and is bound to cause confusion.

The natural cubic splines are very difficult to control. Once you have
gotten one segment to look just right, it can be ruined by any of the next
control points added. One serious result of this is that it's nearly
impossible to make a smoothly closed (looping) spline. When using the spline
type in prisms there's an easy rule to follow which is that the first three
an last points should be identical. But with natural cubic splines I have
yet to succeed to make a loop. Can anybody explain how to do it? Perhaps it
would be a good idea if it was explained in the documentation how to make a
smoothly closed spline with this spline type. It would be very relevant!

The best solution in my opinion would be to call the natural cubic spline by
another name maybe "natural_cubic_spline" and then also have support for the
cubic spline type used in prisms, which is easier to control. But of course,
as usual the answer is "please code it yourself" so I guess there's no hope
of seeing that implemented.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:    http://rsj.mobilixnet.dk (updated Feb 16)
POV-Ray Users:   http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Webring: http://webring.povray.co.uk


Post a reply to this message

From: Mark Wagner
Subject: Re: Cubic spline question
Date: 17 Feb 2002 06:06:41
Message: <3c6f8ec1$1@news.povray.org>
Rune wrote in message <3c6f704e@news.povray.org>...
>Here are the problems I have with the current situation:
>
>Cubic splines are a broad class of spline types, yet in both prisms and
>spline{} it means a very specific spline. This wouldn't matter so much if
it
>was the same one in all features of POV-Ray, but to have the word
>cubic_spline mean different things in different context is very
inconsistent
>and is bound to cause confusion.

If I knew for certain what sort of cubic spline is used in "prism", I'd be
able to duplicate it and add it as another type of pure spline.

--
Mark


Post a reply to this message

Goto Latest 10 Messages Next 7 Messages >>>

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