POV-Ray : Newsgroups : povray.advanced-users : Which spline type corresponds to the bezier_spline lathe? : Re: Which spline type corresponds to the bezier_spline lathe? Server Time
28 Jul 2024 16:20:47 EDT (-0400)
  Re: Which spline type corresponds to the bezier_spline lathe?  
From: Tor Olav Kristensen
Date: 10 Sep 2004 20:53:01
Message: <41424c6d$1@news.povray.org>
Scott Gammans wrote:

> I am pulling what is left of my hair out trying to get this to work. 
> Hopefully an eagle eye in here will spot my error.
> 
> I am trying to create a sweep of spheres using a spline. The sweep 
> should follow along the surface of a bezier_spline lathe object.
> 
> However, none of the spline types (linear, quadratic, cubic, natural) 
> seem to correspond to the bezier_spline lathe. Am I just doing something 
> wrong, or are bezier splines an ommission in the spline object? 

I'm not sure but I believe that the latter is true.


> And if they're an ommission, any suggestions for how to sweep spheres 
> along a bezier spline?

Se below for a possible solution.

Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.6;

#include "colors.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#macro BezierFunction(pStart, vStart, pEnd, vEnd, v0)

   #local pS = vdot(pStart, v0);
   #local vS = vdot(vStart, v0);
   #local pE = vdot(pEnd, v0);
   #local vE = vdot(vEnd, v0);

   #local AA =  2*pS - 2*pE + 3*vS - 3*vE;
   #local BB = -3*pS + 3*pE - 6*vS + 3*vE;
   #local CC =  3*vS;
   #local DD =  pS;

   function(T) { ((AA*T + BB)*T + CC)*T + DD }

#end // macro BezierFunction

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare Points =
   array[8] {
     <0, 10.0, 0.0>,
     <0,  7.5, 0.0>,
     <0,  7.5, 1.5>,
     <0,  5.1, 1.5>,
     <0,  4.9, 1.5>,
     <0,  2.5, 1.5>,
     <0,  2.5, 0.0>,
     <0,  0.0, 0.0>
   }

#declare pA = Points[0];
#declare vA = Points[1] - Points[0];
#declare vB = Points[2] - Points[3];
#declare pB = Points[3];

#declare xFn1 = BezierFunction(pA, vA, pB, vB, x)
#declare yFn1 = BezierFunction(pA, vA, pB, vB, y)
#declare zFn1 = BezierFunction(pA, vA, pB, vB, z)


#declare pC = Points[4];
#declare vC = Points[5] - Points[4];
#declare vD = Points[6] - Points[7];
#declare pD = Points[7];

#declare xFn2 = BezierFunction(pC, vC, pD, vD, x)
#declare yFn2 = BezierFunction(pC, vC, pD, vD, y)
#declare zFn2 = BezierFunction(pC, vC, pD, vD, z)


#declare I = 0;
#while (I <= 1)
   sphere {
     <xFn1(I), yFn1(I), zFn1(I)>, 0.08
     pigment { color Yellow }
   }
   sphere {
     <xFn2(I), yFn2(I), zFn2(I)>, 0.08
     pigment { color Red }
   }
   #declare I = I + 1/32;
#end // while


lathe {
   bezier_spline
   8,
   <0.0, 10.0>,
   <0.0,  7.5>,
   <1.5,  7.5>,
   <1.5,  5.1>,
   <1.5,  4.9>,
   <1.5,  2.5>,
   <0.0,  2.5>,
   <0.0,  0.0>
   pigment { color rgbt <0.5, 0.5, 0.5, 0.6> }
}

union {
   #declare Cnt = 0;
   #while (Cnt < dimension_size(Points, 1))
     sphere { Points[Cnt], 0.1 }
     #declare Cnt = Cnt + 1;
   #end // while
   pigment { color Green }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

background { color (White + Blue)/2 }

light_source {
   <1, 2, 3>*100 color White*2
   shadowless
}

camera {
   orthographic
   location <12, 5, 0>
   look_at <0, 5, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

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