|
![](/i/fill.gif) |
"Mike Williams" <nos### [at] econym demon co uk> wrote in message
news:YM4### [at] econym demon co uk...
> Wasn't it David Cameron who wrote:
> >Hi All,
> >Do any of you know how to produce an elliptical torus?
> >
> >Given the general torus syntax is:
> >torus { major_radius, minor_radius }
> >
> >How could I define:
> >#macro elliptical_torus( x_major_radius, z_major_radius, minor_radius)
> > // which code goes here ?
> >#end
>
> You could do it as a parametric. Just replace the two instances of
> major_radius in the usual parametric equations for the torus by
> x_major_radius and z_major_radius.
>
> #macro elliptical_torus( x_major_radius, z_major_radius, minor_radius)
> #declare Fx = function(u,v){cos(u)*(x_major_radius+minor_radius*cos(v))}
> #declare Fz = function(u,v){sin(u)*(z_major_radius+minor_radius*cos(v))}
> #declare Fy = function(u,v){minor_radius*sin(v)}
>
> #declare C = <x_major_radius+minor_radius, minor_radius,
> z_major_radius+minor_radius>*1.01;
>
> parametric {
> function {Fx(u,v)}
> function {Fy(u,v)}
> function {Fz(u,v)}
> <0,-2>,<2*pi,2*pi>
> contained_by{ box {-C,C}}
> precompute 18, x,y,z
> }
> #end
>
> However, that's a bit slow, so I'd recommend using Ingo Janssen's
param.inc
> to approximate it. It runs about 20 times faster and the results are
> virtually indistinguishable.
>
> #macro elliptical_torus( x_major_radius, z_major_radius, minor_radius)
> #declare Fx = function(u,v){cos(u)*(x_major_radius+minor_radius*cos(v))}
> #declare Fz = function(u,v){sin(u)*(z_major_radius+minor_radius*cos(v))}
> #declare Fy = function(u,v){minor_radius*sin(v)}
>
> #include "param.inc"
>
> object{
> Parametric(
> Fx, Fy, Fz,
> <0,0>,<2*pi,2*pi>,
> 100,40,""
> )
> }
> #end
>
> If you're not familiar with param.inc, see
> <http://www.econym.demon.co.uk/isotut/param.htm>
>
> --
> Mike Williams
> Gentleman of Leisure
Thanks very much Mike,
I went with your param.inc version. It works treat and is pretty fast.
I will need to use several of these in some scenes, so parse time could go
up while the meshes are created, but I can live with that and I am just
happy to have found a solution :)
Cheers,
Dave
Post a reply to this message
|
![](/i/fill.gif) |