POV-Ray : Newsgroups : povray.general : Strange behaviour on cubic_spline Server Time
29 Oct 2024 23:55:07 EDT (-0400)
  Strange behaviour on cubic_spline (Message 1 to 5 of 5)  
From: Manuel Mata Rueda
Subject: Strange behaviour on cubic_spline
Date: 11 Mar 2006 07:00:40
Message: <4412bbe8@news.povray.org>
Hi all.

I noted a strange behaviour on cubic_spline when I define paths with the 
spline  keyword. In previous version of Pov-Ray the first and last 
points of the spline were to set the tangent of the second and the last 
but one point. So the first and last "stretchs" between first-second and 
last but one-last points were straight.

In 3.6 version this is not this way so, why this behaviour on the new 
version or am I wrong ?

Thanks. See ya.


Post a reply to this message

From: Chris B
Subject: Re: Strange behaviour on cubic_spline
Date: 13 Mar 2006 05:57:48
Message: <4415502c$1@news.povray.org>
"Manuel Mata Rueda" <man### [at] yahooes> wrote in message 
news:4412bbe8@news.povray.org...
> Hi all.
>
> I noted a strange behaviour on cubic_spline when I define paths with the 
> spline  keyword. In previous version of Pov-Ray the first and last points 
> of the spline were to set the tangent of the second and the last but one 
> point. So the first and last "stretchs" between first-second and last but 
> one-last points were straight.
>
> In 3.6 version this is not this way so, why this behaviour on the new 
> version or am I wrong ?
>
> Thanks. See ya.

Hi Manuel,

With a cubic_spline the first and last points are just control points and 
don't actually get displayed. Whilst I haven't used cubic_splines much in 
POV-Ray my recollection is that POV-Ray has always been that way, so you 
don't get a straight line at the ends because you don't get any line at the 
ends, the shape starts at the second point and ends at the last-but-one 
point. As you say these control points form tangents to the start and end of 
the curve.

If you think you've found something odd with the behaviour of the 
cubic-spline in 3.6, maybe post a short snippet of SDL to illustrate your 
concern.

Regards,
Chris B.


Post a reply to this message

From: Manuel Mata
Subject: Re: Strange behaviour on cubic_spline
Date: 13 Mar 2006 16:52:50
Message: <4415e9b2$1@news.povray.org>
> If you think you've found something odd with the behaviour of the 
> cubic-spline in 3.6, maybe post a short snippet of SDL to illustrate your 
> concern.

I'll post some code here down here. I'll explain it.
There are 4 points forming a path like a rectangle and 3 splines.
The yellow one is a closed cubic_spline.
With the green one I try to make a closed spline with straight stretchs, 
so I make 4 splines to build it, 2 linear_splines and 2 cubic_splines. 
The points should be tangent but they aren't. If you see the 2 
cubic_splines definition they only define a stretch and have 2 control 
points who should define the tangents at the points.
The blue spline is a simple cubic_spline. I try to draw it fully, from 
the first definition point to the last, but it only draws from the 
second to the last but one as you said before.

You can use camera 1 and 2 with the 'c' var at the end of the code to 
see the tangents. Here is the code.

I think I'm not doing anything badly ...

#version 3.6;
#include "colors.inc"

light_source{<0, 100, 0> White*1.5 parallel point_at <0,0,0>}
plane{y,0 pigment{checker White,Gray75}}

//axis
cylinder{0 x*100 0.1 pigment{Red}}
cylinder{0 z*100 0.1 pigment{Blue}}

//s: spline
//i: first point to draw
//j: last point to draw
//step: interval to place the object
//o: object to place (usually a sphere)
#macro drawSpline(s,i,j,step,o)
   union{
   #local counter = i;
   #while (counter <= j)
     object{o translate s(counter)}
     #local counter = counter + step;
   #end
   }
#end

//objects to draw splines
#declare yellowSphere = sphere{y*1 0.2 pigment{Yellow}}
#declare greenSphere = sphere{y*2 0.1 pigment{Green}}
#declare blueSphere = sphere{y*3 0.05 pigment{Blue}}

//points of spline
#declare p0 = <-6,0,4>;
#declare p1 = < 6,0,4>;
#declare p2 = < 6,0,-4>;
#declare p3 = <-6,0,-4>;

//red spheres to see the spline path
sphere{p0 0.3 pigment{Red}}
sphere{p1 0.3 pigment{Red}}
sphere{p2 0.3 pigment{Red}}
sphere{p3 0.3 pigment{Red}}

//
//splines
//

//from 0 to 3
#declare yellowSpline = spline{
cubic_spline
-1  p3,

0   p0,
1   p1,
2   p2,
3   p3,
4   p0,

5   p1
}

//from 0 to 1
#declare greenSpline_00 = spline{
linear_spline
0  p0,
1  p1,
}
//from 1 to 2
#declare greenSpline_01 = spline{
cubic_spline
0 p0,
1 p1,
2 p2,
3 p3
}
//from 2 to 3
#declare greenSpline_02 = spline{
linear_spline
2  p2,
3  p3,
}
//from 3 to 4
#declare greenSpline_03 = spline{
cubic_spline
2 p2,
3 p3,
4 p0,
5 p1
}



object{drawSpline(yellowSpline,0,4,0.005,yellowSphere)}

object{drawSpline(greenSpline_00,0,1,0.005,greenSphere)}
object{drawSpline(greenSpline_01,1,2,0.005,greenSphere)}
object{drawSpline(greenSpline_02,2,3,0.005,greenSphere)}
object{drawSpline(greenSpline_03,3,4,0.005,greenSphere)}

object{drawSpline(greenSpline_01,0,3,0.005,blueSphere)}

//c: cameras from 1 to 2
#declare c = 1;
#switch(c)
   #case(1) camera {orthographic location <0,15,0> look_at <0,0,0>} #break
   #case(2) camera {orthographic location <6,15,4> direction 3*z look_at 
p1} #break
#end


Post a reply to this message

From: Chris B
Subject: Re: Strange behaviour on cubic_spline
Date: 13 Mar 2006 18:08:02
Message: <4415fb52$1@news.povray.org>
"Manuel Mata" <man### [at] yahooes> wrote in message 
news:4415e9b2$1@news.povray.org...
>  ... snip ... I try to make a closed spline with straight stretchs, so I 
> make 4 splines to build it, 2 linear_splines and 2 cubic_splines. The 
> points should be tangent but they aren't. If you see the 2 cubic_splines 
> definition they only define a stretch and have 2 control points who should 
> define the tangents at the points.

>  ... snip ...

Ahh. I think I see what you are getting at and I need to correct an error in 
my earlier post where I agreed that the first and last points defined for a 
cubic spline form tangents to the start and end of  the curve. As you 
observe through your SDL they don't.  The first and last points in the cubic 
spline are just control points and I believe they are treated in the same 
way as the other cubic spline control points.

WRT your question as to whether this is different between POV-Ray 3.6 and 
earlier versions, I don't think it is different. Certainly the cubic_spline 
examples in the 3.6 help and the 3.5 help look to me to be identical and 
both show what you seem to be showing in your SDL with the first point being 
the same as the third from last point and the last point being the same as 
the third point. In the 3.6 help, this example is in section 2.3.1.3.1 
"Teaching An Old Spline New Tricks". In the 3.5 help it's the same section 
title, but the section number is 3.4.3.1.

Regards,
Chris B.


Post a reply to this message

From: Manuel Mata
Subject: Re: Strange behaviour on cubic_spline
Date: 14 Mar 2006 17:02:11
Message: <44173d63$1@news.povray.org>
> Ahh. I think I see what you are getting at and I need to correct an error in 
> my earlier post where I agreed that the first and last points defined for a 
> cubic spline form tangents to the start and end of  the curve. As you 
> observe through your SDL they don't.  The first and last points in the cubic 
> spline are just control points and I believe they are treated in the same 
> way as the other cubic spline control points.

You are right the are treated like control points, but ... in 3.6 docs 
'3.2.1.9 Spline Identifiers' section there is a 'Note' that says:

"Note: Because of the way cubic_splines are defined: the first and last 
points are tangents rather than points on the spline, cubic_spline 
interpolation is only valid between the second and next-to-last points ..."

I should read that and get confused. That note may is not well writen.

> WRT your question as to whether this is different between POV-Ray 3.6 and 
> earlier versions, I don't think it is different ...

What's the meaning of WRT ? Anyway you're right again, but ... I read 
this tutorial at http://pandora.inf.uni-jena.de/p/e/noo/povsp/use.html 
and probably get confused again. If you download and render the samples 
you won't get the straight lines as we commented before, but ... I you 
render them with Megapov 0.7g you'll see the straight stretch.

I think to remember that I began to use splines with Megapov so that's 
why I probably were confused. I know that Megapov is unofficial so the 
'control points' version of the cubic_spline is the only valid one.

Finally: first and last points are only 'control points'.

But I won't tire out. I'm tryin to build a spline that extends 
cubic_spline. I had some #macros anywhere in my Old Hard Disk using 
Hermite interpolation and with those #macros I had a spline where I 
could create straight and curves stretch inside the same spline and with 
continuity.

Anyway thanks Chris B. See ya.

                  Manuel Mata.
                  http://www.mmata.org


Post a reply to this message

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