|
|
This example is based on method described at
http://news.povray.org/6lpkut0vdh0h6gljr7u2v4mip6olddkmel%404ax.com
I do not added much comments. Names of macros and variables should explain it
clear. Add your favourite spline type.
#version 3.5;
#include "strings.inc"
#macro Create_Spline_With_Remembered_Points(List)
#local Size=dimension_size(List,1);
#local A=array[3];
#local A[0]=array[1];
#local A[1]=array[Size];
#local A[2]=array[Size];
#local C=0;
#while (C<Size)
#local V=<List[C].x,List[C].y,List[C].z>;
#local T=List[C].t;
#local A[0][0]=spline{ #if(C) A[0][0] #end T , V };
#local A[1][C]=T;
#local A[2][C]=V;
#local C=C+1;
#end
A
#end
#macro Get_Spline_Dimension(Extended_Spline_Structure)
dimension_size(Extended_Spline_Structure[1],1)
#end
#macro Get_Nth_T_Param(N,Extended_Spline_Structure)
(
#if(N<Get_Spline_Dimension(Extended_Spline_Structure))
Extended_Spline_Structure[1][N]
#else
#error "Index for spline out of range"
#end
)
#end
#macro Get_Nth_Control_Point(N,Extended_Spline_Structure)
(
#if(N<Get_Spline_Dimension(Extended_Spline_Structure))
Extended_Spline_Structure[2][N]
#else
#error "Index for spline out of range"
#end
)
#end
#macro Evaluate_Extended_Spline(T,Extended_Spline_Structure)
(Extended_Spline_Structure[0][0](T))
#end
#local Extended_Spline=Create_Spline_With_Remembered_Points(
// 4D components where 4th one is time parameter
array[3]{
<1,0,0,-.5>
<0,1,0,0>
<0,0,1,.5>
}
);
#local Size=Get_Spline_Dimension(Extended_Spline);
#local Param=Get_Nth_T_Param(1,Extended_Spline);
#local ControlPoint=Get_Nth_Control_Point(1,Extended_Spline);
#local Point=Evaluate_Extended_Spline(.25,Extended_Spline);
#debug concat("number of control points: ",str(Size,0,0),"\n")
#debug concat("second control point: ",str(Param,0,-1),
",",VStr(ControlPoint),"\n")
#debug concat("evaluated point: s(.25)=",VStr(Point),"\n")
ABX
Post a reply to this message
|
|