POV-Ray : Newsgroups : povray.general : Is it possible to move a torus? : Re: Is it possible to move a torus? Server Time
5 Aug 2024 20:20:32 EDT (-0400)
  Re: Is it possible to move a torus?  
From: Christopher James Huff
Date: 2 Aug 2002 14:09:27
Message: <chrishuff-D3AA17.13001402082002@netplex.aussie.org>
In article <3D4ABA1E.533A0C06@aol.com>, Dave Dunn <poi### [at] aolcom> 
wrote:

> This may be a bit much on this subject, but here is some code showing 
> how a Torus macro might work. I am not happy with having to declare 
> the variables for the normals outside the macro, but don't have time 
> to really think about it right now. The cleanest way would be to just 
> remember that normal y is 0, x is 1 and z is 2, but I wanted a 
> clearer version for this example.

You could have just used x, y, and z, though the logic for finding the 
axis would be a bit more complex. Best would be something like this, 
which can use any axis (rearranged the parameters to be more consistent 
with the built-in shapes):

#include "transforms.inc"
#macro Torus(Center, Axis, MajorRadius, MinorRadius)
    torus {MajorRadius, MinorRadius
        Point_At_Trans(Axis)
        translate Center
    }
#end

The "sturm" flag is a problem...you could either have this macro 
generate sturm or non-sturm torii, or you could add another parameter 
that will always have to be given because macros don't have default 
parameter values. You could just leave out the last } bracket, so the 
macro usage would be like:

Torus(< 0, 0, 0>, < 1, 2, 3>, 1, 0.2)
    sturm
    texture {...}
}

This would make it easier for other things, like textures, hollow and 
inverse, etc...you wouldn't have to wrap the macro call in an object {} 
block. Brackets don't match up though, which may annoy some people.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

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