POV-Ray : Newsgroups : povray.text.scene-files : Twisted Iso Torus Server Time
31 Oct 2024 12:15:30 EDT (-0400)
  Twisted Iso Torus (Message 1 to 3 of 3)  
From: Mike Williams
Subject: Twisted Iso Torus
Date: 5 Jul 2000 13:10:26
Message: <B9hbiBAgNvY5EwOp@econym.demon.co.uk>
/* 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

From: Chris Huff
Subject: Re: Twisted Iso Torus
Date: 6 Jul 2000 10:57:15
Message: <chrishuff-0BB98A.09572906072000@news.povray.org>
In article <B9h### [at] econymdemoncouk>, Mike Williams 
<mik### [at] econymdemoncouk> wrote:

> /* 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.
> */

It can also be done as a non-parametric equation, like this:

#declare Angle = function {atan2(x, y)*z}
// Angle(CoordinateA, CoordinateB, Frequency)

#declare R0 = 2;//Major radius
#declare R1 = 0.5;//Minor radius
#declare A = 0.2;//Ridge amplitude
#declare NT = 8;//Number of twists
#declare NR = 3;//Number of ridges
#declare twistTorFunc = 
function {
        sqrt(sqr(sqrt(sqr(x)+sqr(z)) - R0)+sqr(y))
        -R1+cos(Angle(x,z,NT)+Angle(sqrt(sqr(x)+sqr(z)) - R0,y,NR))*A
}

isosurface {
    function {twistTorFunc(x,y,z)}
    threshold 0
    eval
    max_gradient 2
    contained_by {box {<-3,-1, 0>, < 3, 1, 3>}}
    pigment {color rgb <1,1,0.35>}
}

It's a lot shorter, too. :-)

-- 
Christopher James Huff - Personal e-mail: chr### [at] maccom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/


Post a reply to this message

From: Bill DeWitt
Subject: Re: Twisted Iso Torus
Date: 7 Jul 2000 10:22:27
Message: <3965e7a3$1@news.povray.org>
"Chris Huff" <chr### [at] maccom> wrote :
>
> #declare NT = 8;//Number of twists
> #declare NR = 3;//Number of ridges


    Number of twists are actually NT/NR, which gives you one twist for NT=
X, NR = X

    But I found that NT = X, NR = X+1 give you a nice mobius type surface.

    Great fun for all concerned, thanks Chris. Now if you would just make us
a nice branching tree IsoSurface...


Post a reply to this message

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