POV-Ray : Newsgroups : povray.advanced-users : Which spline type corresponds to the bezier_spline lathe? Server Time
24 Nov 2024 23:42:44 EST (-0500)
  Which spline type corresponds to the bezier_spline lathe? (Message 1 to 5 of 5)  
From: Scott Gammans
Subject: Which spline type corresponds to the bezier_spline lathe?
Date: 10 Sep 2004 10:56:45
Message: <4141c0ad$1@news.povray.org>
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? And if 
they're an ommission, any suggestions for how to sweep spheres along a 
bezier spline?

Thanks!
Scott Gammans
Washington, DC

===============

//Test scene follows:

#global_settings {
     assumed_gamma 1
     max_trace_level 5
}

#declare testTexture = texture {
     pigment {color rgb 1}
}

// Here's the bezier_spline lathe along which
// I want to sweep some spheres:
lathe {
	bezier_spline
	8
	<0.0,10.0>
	<0.0,7.5>
	<1.5,7.5>
	<1.5,5.0>
	<1.5,5.0>
	<1.5,2.5>
	<0.0,2.5>
	<0.0,0.0>
	sturm
   	texture {testTexture}
	translate <0,-5,-5.5>
}

// Here's the spline, which has the same u,v points:
#local sphereSpline = spline {
	0,<0.0,10.0>
	1,<0.0,7.5>
	2,<1.5,7.5>
	3,<1.5,5.0>
	4,<1.5,5.0>
	5,<1.5,2.5>
	6,<0.0,2.5>
	7,<0.0,0.0>
}

// Linear spline definitely doesn't match:
union {
	#local ctr=0;
	#while (ctr<=7)
		sphere {sphereSpline(ctr,linear_spline),0.25}
		#declare ctr=ctr+0.01;
	#end
   	texture {testTexture}
   	rotate y*90
	translate <0,-5,-1.5>
}

// Neither does quadratic_spline:
union {
	#local ctr=0;
	#while (ctr<=7)
		sphere {sphereSpline(ctr,quadratic_spline),0.25}
		#declare ctr=ctr+0.01;
	#end
   	texture {testTexture}
   	rotate y*90
	translate <0,-5,1>
}

// Nor does cubic_spline:
union {
	#local ctr=0;
	#while (ctr<=7)
		sphere {sphereSpline(ctr,cubic_spline),0.25}
		#declare ctr=ctr+0.01;
	#end
   	texture {testTexture}
   	rotate y*90
	translate <0,-5,3.5>
}

// Nor does natural_spline:
union {
	#local ctr=0;
	#while (ctr<=7)
		sphere {sphereSpline(ctr,natural_spline),0.25}
		#declare ctr=ctr+0.01;
	#end
   	texture {testTexture}
   	rotate y*90
	translate <0,-5,6>
}

light_source {
	x*1000
	color rgb 0.25
}

camera {
	orthographic
	location x*7
	look_at 0
	angle 90
	right image_width/image_height*x
	up y
}


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Which spline type corresponds to the bezier_spline lathe?
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

From: Scott Gammans
Subject: Re: Which spline type corresponds to the bezier_spline lathe?
Date: 13 Sep 2004 11:26:00
Message: <4145BC06.8020308@yahoo.com>
Thank you Tor! That appears to track perfectly.

I am really surprised that there is not a built-in method for using 
Bezier splines the way that there is for the other four spline types 
(linear, quadratic, cubic, natural). Hopefully this oversight will be 
addressed in the next major release of POV-Ray.

Thanks again for your assistance, Tor!

-----
Scott Gammans
Washington, DC


Tor Olav Kristensen wrote:
> 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

From: ABX
Subject: Re: Which spline type corresponds to the bezier_spline lathe?
Date: 13 Sep 2004 12:55:20
Message: <hljbk0tjqsl3u6aku7aoiparp6gpctaf1n@4ax.com>
On Mon, 13 Sep 2004 11:25:58 -0400, Scott Gammans
<dee### [at] yahoocom> wrote:
> I am really surprised that there is not a built-in method for using 
> Bezier splines the way that there is for the other four spline types 
> (linear, quadratic, cubic, natural). Hopefully this oversight will be 
> addressed in the next major release of POV-Ray.

spline{}, sor{}, prism{}, lathe{}, text{}, sphere_sweep{}, polygon{}

are basically all look like use splines but in fact they are almost
independend. IIRC spline{} feature was introduced much later than lathe by
pesons not related to original code. Adding new types to spline{} is kind of
trivial (at least from my perspective of adding even complex types at
http://megapov.inetart.net/manual-1.1/expressions.html#splines ) so if anyone
wants to try it ... :-)

ABX


Post a reply to this message

From: Scott Gammans
Subject: Re: Which spline type corresponds to the bezier_spline lathe?
Date: 13 Sep 2004 13:50:24
Message: <4145DDE1.4050308@yahoo.com>
Yes, that actually makes sense... spline{} was introduced in POV-Ray 
3.5, was it not? The lathe object was around long before that.

-----
Scott Gammans
Washington, DC


ABX wrote:
> On Mon, 13 Sep 2004 11:25:58 -0400, Scott Gammans
> <dee### [at] yahoocom> wrote:
> 
>>I am really surprised that there is not a built-in method for using 
>>Bezier splines the way that there is for the other four spline types 
>>(linear, quadratic, cubic, natural). Hopefully this oversight will be 
>>addressed in the next major release of POV-Ray.
> 
> 
> spline{}, sor{}, prism{}, lathe{}, text{}, sphere_sweep{}, polygon{}
> 
> are basically all look like use splines but in fact they are almost
> independend. IIRC spline{} feature was introduced much later than lathe by
> pesons not related to original code. Adding new types to spline{} is kind of
> trivial (at least from my perspective of adding even complex types at
> http://megapov.inetart.net/manual-1.1/expressions.html#splines ) so if anyone
> wants to try it ... :-)
> 
> ABX


Post a reply to this message

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