|
![](/i/fill.gif) |
/* It's possible to create a twisted torus as a parametric isosurface.
What I've done here is to work out a set of parametric equations for
a torus, and then apply a cyclic displacement factor.
The size of the major and minor radii, the number of twists and the
amplitude of the twist displacement are all configurable.
*/
#version unofficial MegaPov 0.5;
camera { location <1, 2, -4> look_at <0, 0, 0> angle 24}
sky_sphere { pigment {
gradient y
color_map { [0.0 color blue 0.6] [1.0 color rgb 1] }
}
}
light_source {<100,200,-100> colour rgb 1}
light_source {<-100,-200,-100> colour rgb 0.5}
//=============================================
#declare R1 = 0.6; // major radius
#declare R2 = 0.2; // minor radius
#declare N=6; // Number of twists
#declare A=0.1; // Amplitude of twist
// The parametric description of a twisted torus
// It's just the parameters of an ordinaty torus with an extra term
// tagged on the end of each line that describes the twisty displacement
#declare Fx = function { R2*cos(v)*cos(u) + R1*cos(u)*(1+A*cos(N*u))}
#declare Fy = function { R2*sin(v) + A*sin(N*u) }
#declare Fz = function { R2*cos(v)*sin(u) + R1*sin(u)*(1+A*cos(N*u))}
// Calculate size of the contained_by box
// (adding a slight fudge factor, which needs to be at least 2*accuracy)
#declare Rx = R1 + R2 + A + 0.02;
#declare Ry = R2 + A + 0.02;
#declare Rz = R1 + R2 + A + 0.02;
parametric {
function
Fx(u,v,0), Fy(u,v,0), Fz(u,v,0) // The parametric functions
<0,0>,<2*pi,2*pi> // u and v bopth in the range 0 to 2*pi
<-Rx,-Ry,-Rz>,<Rx,Ry,Rx> // the contained_by box
accuracy 0.0001
precompute 18, [x,y,z]
pigment {rgb 0.9}
finish {phong 0.5 phong_size 10}
}
Post a reply to this message
|
![](/i/fill.gif) |