POV-Ray : Newsgroups : povray.general : Elliptical Torus? : Re: Elliptical Torus? Server Time
2 Aug 2024 08:12:13 EDT (-0400)
  Re: Elliptical Torus?  
From: Mike Williams
Date: 11 Feb 2005 13:11:34
Message: <TIAndBAwSPDCFwYm@econym.demon.co.uk>
Wasn't it David Cameron who wrote:
>
>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 :)

Did you know that you can re-use the meshes if you happen to want ones with
the same dimensions? Even if they are in different scene files?

If you pass param.inc a filename, as show below, it will look to see if a
file of that name exists, if not it will create the mesh from the supplied
parameters and write a file containing the mesh data. If the file already
exists, it ignores the other parameters and reads the mesh directly from the
file, saving all that parse time. 

#macro elliptical_torus( x_major_radius, z_major_radius,
  minor_radius, filename)       // changed here
  #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,filename          // and here
    )
  }
#end

Call it like
  object {elliptical_torus(2,1,0.4,"ET2_1_04.DAT")
    texture {...}
  }

You just need to be careful to change the filename when you change any of
the other parameters.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.