POV-Ray : Newsgroups : povray.beta-test : [Doc] new cubic_spline type endpoints : [Doc] new cubic_spline type endpoints Server Time
29 Jul 2024 20:24:10 EDT (-0400)
  [Doc] new cubic_spline type endpoints  
From: Mike Williams
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

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