|
|
I think I managed to convert a sphere_sweep to a parametric object (well
almost).
Here is an example just in case anyone is interested. I haven't finished it
yet but it should work... Warning It take's a while to parse and render!
//------------------------------
//An example of converting a sphere_sweep to a parametric object by:Pyry
Pakkanen
global_settings{ assumed_gamma 1 }
#include "functions.inc"
camera{
location <0,2,-3>
look_at <0,0,0>
}
background {color rgb<0.91,0.92,0.95>}
light_source{<-100,100,-100> color rgb 1}
#declare S = function {
spline {
natural_spline
0, < 1, 0, 0.0>,
0.25, < 0, 0.25, -1>,
0.5, < -1, 0.5, 0>,
0.75, < 0, 0.75, 1>,
1, < 1, 1, 0 >,
}
}
#declare n = 0.01; //The accuracy for the "derivation"
#declare DELTA_x = function(u) {S(u+n).x-S(u).x}
#declare DELTA_y = function(u) {S(u+n).y-S(u).y}
#declare DELTA_z = function(u) {S(u+n).z-S(u).z}
#declare PHI = function(u) {f_ph(DELTA_x(u),DELTA_y(u),DELTA_z(u))}
#declare THETA = function(u) {f_th(DELTA_x(u),DELTA_y(u),DELTA_z(u))}
#declare Radius = .2;
parametric{
#declare f_x =
function(u,v){S(u).x+cos(THETA(u))*sin(v)*Radius+sin(THETA(u))*cos(PHI(u))*cos(v)*Radius}
function{f_x(u,v)}
#declare f_y = function(u,v){S(u).y+sin(PHI(u))*cos(v)*Radius}
function{f_y(u,v)}
#declare f_z =
function(u,v){S(u).z+cos(THETA(u))*cos(PHI(u))*cos(v)*Radius-sin(THETA(u))*sin(v)*Radius}
function{f_z(u,v)}
<0,0>,<1-n,2*pi> //note 2-n! DELTA_x,DELTA_y and DELTA_z would continue
beyond the spline's range. This prevents it.
contained_by{box{-pi*100,pi*100}}
max_gradient 0
accuracy 0.01
precompute 16 x,y,z
pigment{color red 1}
no_shadow
}
Post a reply to this message
|
|