#macro _ikn_spline (_ikn_sv) // macro that calculates spline positions +pow(1-_ikn_sv,3)*_ikn_2 +pow( _ikn_sv,3)*_ikn_3 +pow(1-_ikn_sv,2)*3* (_ikn_sv )*(2*_ikn_2-_ikn_1) + (1-_ikn_sv )*3*pow(_ikn_sv,2)*(2*_ikn_3-_ikn_4) #end #declare _ikn_length = vlength(ikn_p1-ikn_p2); // the length between the startpoint and the endpoint #declare _ikn_linklength = ikn_length/ikn_links; // the length of each "link" #declare _ikn_m = 100; // we will adjust this until we get a spline of suitable length #declare _ikn_len = 0; // variable to hold the calculated spline length #declare _ikn_max_err = ikn_length*0.01 // spline should be within, say, 1% of correct length #while( abs(_ikn_len - ikn_length) > _ikn_max_err)// loop until spline is within tollerance #declare _ikn_1 = vnormalize(ikn_v1)*_ikn_length*_ikn_m+ikn_p1; // startnormal is made non-relative to startpoint. #declare _ikn_2 = ikn_p1; #declare _ikn_3 = ikn_p2; #declare _ikn_4 = vnormalize(ikn_v2)*_ikn_length*_ikn_m+ikn_p2; // endnormal is made non-relative to endpoint. // Creates an array with link positions based on a spline. #declare _ikn_spos = array[ikn_links] #declare _ikn_x = 0; // counter for the #while loop just below. #declare _ikn_len = 0; #while (_ikn_x}} #if (_ikn_x > 0) #declare _ikn_len = _ikn_len + vlength(_ikn_spos[_ikn_x]-_ikn_spos[_ikn_x-1]); #end #declare _ikn_x = _ikn_x+1; #end #if (_ikn_len > ikn_length) #declare _ikn_m = _ikn_m * 0.5; // if spline too long, reduce end vectors #else #declare _ikn_m = _ikn_m * 1.5; // if spline too long, increase end vectors #end #debug "length = " #debug str(_ikn_len,5,4) #debug "\n" #end // // make the points visible in the scene #declare _ikn_x = 1; // counter for the #while loop just below. #while (_ikn_x}} #declare _ikn_x = _ikn_x+1; #end