POV-Ray : Newsgroups : povray.beta-test : [Doc] new cubic_spline type endpoints Server Time
1 Nov 2024 21:20:11 EDT (-0400)
  [Doc] new cubic_spline type endpoints (Message 1 to 4 of 4)  
From: Mike Williams
Subject: [Doc] new cubic_spline type endpoints
Date: 7 Mar 2002 13:05:48
Message: <OvTk0BAAy0h8EwDX@econym.demon.co.uk>
I think it would be a good idea to mention that the new cubic_spline
requires an extra control point at each end.

The natural_spline, quadratic_spline and linear_spline don't require
these extra control points.

Old scenes that used the whole length of an old cubic_spline have a
tendency to explode when they reach the final point, because the of the
new cubic_spline at the final control point has a tendency to evaluate
to <-1.#IND00,-1.#IND00,-1.#IND00>. 

In this example scene, when using the whole length of a cubic_spline
(it's tricky to stop at the penultimate control point when using spline
functions to generate isosurfaces), the isosurface that uses the spline
explodes, and the spline evaluates to <-1.#IND00,-1.#IND00,-1.#IND00> at
the endpoint. Replace "cubic_spline" by any other spline type and the
isosurface behaves normally, and the spline evaluates to <0,0,-0.6>.

camera {
  location  <4, 0, -5> 
  look_at <0, 0.25, 0>
  angle 25
}

background {rgb 1}

light_source {<100,200,-100> colour rgb 1.5}

#declare S = function {
   spline {
     cubic_spline
      -1, < 0, 0.5, 0.0>,
    -0.5, < 0, 0.2, 0.4>,
    0.01, < 0, 0.2, 0.2>,
     0.5, < 0, 0.4, 0.4>,
       1, < 0, 0.0,-0.6>
   }
 }


isosurface {
  function { (y - S(x).y)^2 + (z - S(x).z)^2 - 0.05 }
  max_gradient 4
  contained_by{box{-1,1}}   open
  pigment {rgb x}
}

#declare ctr = 1;
#debug concat("\n<"str(S(ctr).x,5,-1), ", "
  str(S(ctr).y,5,-1), ", "
  str(S(ctr).z,5,-1), ">\n\n"
)


Post a reply to this message

From: ingo
Subject: Re: [Doc] new cubic_spline type endpoints
Date: 7 Mar 2002 15:58:15
Message: <Xns91CADFD822EFBseed7@povray.org>
in news:OvT### [at] econymdemoncouk Mike Williams wrote:

> I think it would be a good idea to mention that the new cubic_spline
> requires an extra control point at each end.

I'll do so,

Ingo


Post a reply to this message

From: Mark Wagner
Subject: Re: [Doc] new cubic_spline type endpoints
Date: 7 Mar 2002 23:47:40
Message: <3c88426c@news.povray.org>
Mike Williams wrote in message ...
>In this example scene, when using the whole length of a cubic_spline
>(it's tricky to stop at the penultimate control point when using spline
>functions to generate isosurfaces), the isosurface that uses the spline
>explodes, and the spline evaluates to <-1.#IND00,-1.#IND00,-1.#IND00> at
>the endpoint. Replace "cubic_spline" by any other spline type and the
>isosurface behaves normally, and the spline evaluates to <0,0,-0.6>.

It shouldn't be doing that.  It should be evaluating to <0, 0.4, 0.4> at any
point beyond the next-to-last.  I'll see if I can find the bug.

--
Mark


Post a reply to this message

From: Mark Wagner
Subject: Re: [Doc] new cubic_spline type endpoints
Date: 10 Mar 2002 23:39:36
Message: <3c8c3508$1@news.povray.org>
Mark Wagner wrote in message <3c88426c@news.povray.org>...
>Mike Williams wrote in message ...
>>In this example scene, when using the whole length of a cubic_spline
>>(it's tricky to stop at the penultimate control point when using spline
>>functions to generate isosurfaces), the isosurface that uses the spline
>>explodes, and the spline evaluates to <-1.#IND00,-1.#IND00,-1.#IND00> at
>>the endpoint. Replace "cubic_spline" by any other spline type and the
>>isosurface behaves normally, and the spline evaluates to <0,0,-0.6>.
>
>It shouldn't be doing that.  It should be evaluating to <0, 0.4, 0.4> at
any
>point beyond the next-to-last.  I'll see if I can find the bug.

An embarrassingly obvious bug: it's trying to do Catmull-Rom interpolation
from three valid data points and one invalid one.  The fix:
In section "case CATMULL_ROM_SPLINE:" of Get_Spline_Val(), change the line
                else if(i == last)
to
                else if(i >= last)

--
Mark


Post a reply to this message

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