#include "functions.inc" #include "math.inc" #include "colors.inc" #include "camera_functions.inc" #include "cubic_splines final1.inc" #declare CONTROL = 15; // number of control points in SPLINE #declare CUBE_DIM = 1000; // dimension of cube used for random point generation #declare ACCURACY = .001; // accuracy of the refecernce spline (KINETIC_SPLINE) #declare BAIL = 2; // number of passes KINETIC_SPLINE will make /* This will create a graph of how accurate the reference spline is. The red line is the original error of the SPLINE. The green line is the error rate using the created reference spline once a reference spline is created with KINETIC_SPLINE, it's used as such say for instance, SPLINE = the original spline LENGTH = length of SPLINE REF = KINETIC_SPLINE (SPLINE,ACCURACY,BAIL) if you wanted the time value to get to %50 of the length of SPLINE DISTANCE = 0.5 * LENGTH (%50 of the length) TIME = REF(DISTANCE).x therefore, SPLINE(TIME) should closely equal DISTANCE */ Basic_Camera ((Rotsph(0,180,50)), <0,0,0>) Camera_TPR (0,0,0) //Set_Position(CP) //Set_Target(CT) //Set_Right(RT) //Set_Up(UP) //Set_Fov(170) //Set_Truck(<0,0>) //Set_Roll(45) //Set_Tilt(TL) //Set_Pan(PN) //Set_Cam_Dolly(0) //Set_Tar_Dolly(TD) //Set_All_Dolly(AD) //Set_Perspective(160) //Set_Fov_Rate(FR) //Set_Dolly_Rate(.5) Create_Camera() #local line_color = texture { pigment { rgb <1,1,0> } finish { ambient 1 } } #local disp_color = texture { pigment { rgb <1,0.1,0.1> } finish { ambient 1 } } #local b_color = texture { pigment { rgb <0,1,0> } finish { ambient 1 } } #local ab_color = texture { pigment { rgb <0,0,1> } finish { ambient 1 } } #macro GEN_DATA (NUM) #local Ran = seed(NUM); #local bound = CUBE_DIM; #local D = array [NUM]; #local I = 0; #while (I < NUM) #local Xp = RRand(-bound,bound,Ran); #local Yp = RRand(-bound,bound,Ran); #local Zp = RRand(-bound,bound,Ran); #local D[I] = ; #local I = I + 1; #end D #end #declare points = GEN_DATA(CONTROL) #declare this_path = Estimate_Cubic_Spline (points) #local DATA = array [4] {<-0.5,-0.5,0>,<0,0,0>,<1,1,0>,<1.5,1.5,0>} #local TIME = array [4] {-0.5,0,1,1.5} #declare working = Create_Spline (DATA,TIME) #declare LENGTH = segment_length (this_path,0,1,0.0001); #local Start = -30; #local End = 30; #local xmin = 0; #local xmax = 1; #local mag = 500; #local step = 100; #local fstep = (xmax - xmin) / step; #local dstep = (End - Start) / step; #local drange = (End - Start); #local STATS = array [(step+1)] #local iter = 0; #local pos = Data; #local lpos = Set(0,0,0); #local ldx = Start- .00001; #local ldy = 0; #while (iter <= step) sphere {<(Start + (iter * dstep)),0,0>,.15 texture {line_color}} #local pos = Set ((xmin + (iter * fstep)),0,0); #local F_eval = FUNC_AB (lpos,pos,this_path,working,LENGTH,); #local dx = ((( iter / step) * drange) + Start); #local dy = (F_eval[2] * mag); cylinder {,,.1 texture {disp_color}} #local STATS[iter] = abs (F_eval[2]); #local lpos = F_eval; #local iter = iter + 1; #local ldx = dx; #local ldy = dy; #end GetStats (STATS) // THIS IS WHERE THE REFERENCE SPLINE IS MADE // it isn't used they way it would normally since I'm just showing the error here with FUNC_AB #declare working = KINETIC_SPLINE (this_path,ACCURACY,BAIL) #local iter = 0; #local pos = Data; #local lpos = Set(0,0,0); #local ldx = Start- .00001; #local ldy = 0; #while (iter <= step) sphere {<(Start + (iter * dstep)),0,0>,.15 texture {line_color}} #local pos = Set ((xmin + (iter * fstep)),0,0); #local F_eval = FUNC_AB (lpos,pos,this_path,working,LENGTH); #local dx = ((( iter / step) * drange) + Start); #local dy = (F_eval[2] * mag); cylinder {,,.1 texture {b_color}} #local STATS[iter] = abs (F_eval[2]); #local lpos = F_eval; #local iter = iter + 1; #local ldx = dx; #local ldy = dy; #end GetStats (STATS)