|
|
Rune wrote:
>>Thus, a trick would be to "go round byond the end point".
>>I.e to use a additional control point that is identical with
>>the second point on the curve.
>>
>
> I thought this was exactly what I had done in my example code?
> I didn't understand you. I would appreciate if you could look at my example
> code and show me how to change it to get a smooth connection.
Sorry, Rune, indeed I was in hurry and overlooked, that you had added
an additional point at the start. So this was my fault.
In cases where it has to bee *realy* smooth, one additional point
often is not sufficient. I found myself using sometimes three or four.
Some weeks ago, I had to create lots of closed splies, so I wrote a
short macro, see below enclosed in your example.
Hermann
#macro nat_closed(o)
#if (o<=0)
#error "number of additional control points needs be >0\n"
#end
#declare u_nr=0;
#declare o_nr=0;
#declare firstPts=array[o+1];
#declare firstVec=array[o+1];
#declare lastPts =array[o];
#declare lastVec =array[o];
#declare over=o;
spline { cubic_spline
#end
#macro CP(pt,V)
pt, V,
#if (u_nr<over+1)
#declare firstPts[u_nr]=pt;
#declare firstVec[u_nr]=V;
#end
#declare lastPts[o_nr]=pt;
#declare lastVec[o_nr]=V;
#declare u_nr=u_nr+1;
#declare o_nr=mod(o_nr+1,over);
#end
#macro join_it(join_at)
#if (u_nr<over+1)
#error concat("only ",str(u_nr-1,0,0)," additional control points
possible with this data\n")
#end
#local i=0;
#while(i<over+1)
join_at+firstPts[i]-firstPts[0], firstVec[i],
#local i=i+1;
#end
#local i=0;
#while(i<over)
firstPts[0]+lastPts[i]-join_at, lastVec[i],
#local i=i+1;
#end
}// end generated spline declaration
#end
camera {location 4*y look_at 0 translate z}
light_source {1000*y, color 1}
plane {y, 0 pigment {checker color rgb 1.0, color rgb 0.9}}
#declare Spline = nat_closed(3) // <--- No of additional control pts
CP( 0, < 0,0,0>) // P3 red joining point
CP( 1, < 1,0,0>) // P4
CP( 2, < 2,0,2>) // P5
CP( 8, <-2,0,2>) // P1
CP( 9, <-1,0,0>) // P2
join_it(10)
#declare C = 0;
#while (C<=200)
#declare V = C/20;
sphere {Spline(V), 0.02 pigment {color <1,0,0>}}
#declare C = C+1;
#end
#declare C = 0;
#declare Cm = 400;
#while (C<=Cm)
#declare V = C/Cm;
#declare T0 = mod((C-1)/40+5,10);
#declare T1 = mod( C /40+5,10);
#declare T2 = mod((C+1)/40+5,10);
sphere {
<-2+4*C/Cm
0,
1+100*vlength(
+(Spline(T1)-Spline(T0))
-(Spline(T2)-Spline(T1))
)
>
0.02
pigment {color <0,0,1>}}
#declare C = C+1;
#end
Post a reply to this message
|
|