POV-Ray : Newsgroups : povray.general : Elliptical Torus? Server Time
13 Oct 2026 02:06:19 EDT (-0400)
  Elliptical Torus? (Message 1 to 21 of 21)  
From: David Cameron
Subject: Elliptical Torus?
Date: 9 Feb 2005 15:10:04
Message: <420a6e1c$1@news.povray.org>
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

TIA,
Dave


Post a reply to this message

From: Neil Kolban
Subject: Re: Elliptical Torus?
Date: 9 Feb 2005 15:15:21
Message: <420a6f59$1@news.povray.org>
Dave,
I consider myself a bit of a newbie ... but wouldn't a regular torus 
followed by a scale in some direction now do what you want?

Neil

"David Cameron" <nom### [at] tome> wrote in message 
news:420a6e1c$1@news.povray.org...
> 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
>
> TIA,
> Dave
>
>


Post a reply to this message

From: Warp
Subject: Re: Elliptical Torus?
Date: 9 Feb 2005 15:23:53
Message: <420a7159@news.povray.org>
Neil Kolban <kol### [at] kolbancom> wrote:
> I consider myself a bit of a newbie ... but wouldn't a regular torus 
> followed by a scale in some direction now do what you want?

  That wouldn't keep the minor radius constant.

  I suppose that if you want an elliptical torus with the minor radius
constant, you'll need to write a 5th or 6th order polynomial (either
with poly or isosurface). I'm too lazy right now to even try to start
guessing the proper formula.
  Of course another way is to cheat and create a mesh instead using
a nested loop.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Neil Kolban
Subject: Re: Elliptical Torus?
Date: 9 Feb 2005 15:33:41
Message: <420a73a5@news.povray.org>
Aha!! Good point.

How about a sphere_sweep.  The sphere_sweep follows a spline which could 
have a maximum and minimum "orbit" (apogee/perigee?).  The Spheres are all 
the same radius and hence the shape would have the same "width" along its 
surfaces.

Neil


Post a reply to this message

From: Warp
Subject: Re: Elliptical Torus?
Date: 9 Feb 2005 15:43:07
Message: <420a75db@news.povray.org>
Neil Kolban <kol### [at] kolbancom> wrote:
> How about a sphere_sweep.  The sphere_sweep follows a spline which could 
> have a maximum and minimum "orbit" (apogee/perigee?).  The Spheres are all 
> the same radius and hence the shape would have the same "width" along its 
> surfaces.

  That would probably only be an approximation of an elliptical torus,
but I bet he is not looking for the mathematically exact result
anyways... :P

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Rick Measham
Subject: Re: Elliptical Torus?
Date: 9 Feb 2005 21:50:08
Message: <420acbe0@news.povray.org>
David Cameron wrote:
> How could I define:
> #macro elliptical_torus( x_major_radius, z_major_radius, minor_radius)
>   // which code goes here ?
> #end

I nervously submit the following. I'm no POV-God but this works for me.

Because of the nature of splines, declaring the four points on the 
compass (plus overlapping to close the shape) we turn it into a perfect 
ellipse. However, because of the nature of POV's b_spline we need to 
scale the elipse by (it seems) 150%.

Anyway, what I'm trying to say is that the following works.

__SCENE__
// Persistence of Vision Ray Tracer Scene Description File
// File: etorus.pov
// Vers: 3.5
// Desc: Example of an eliptical torus
// Date: 2005-02-10
// Auth: Rick Measham
// Licn: LGPL (http://www.gnu.org/copyleft/lesser.html)

#version 3.5;

#include "colors.inc"

// ----------------------------------------

// Look down rather than rotate all objects :)
camera {
   location  <0.0, 50, 0>
   direction 1.5*z
   right     x*image_width/image_height
   look_at   <0.0, 0.0,  0.0>
}

sky_sphere {
   pigment {
     gradient y
     color_map {
       [0.0 rgb <0.6,0.7,1.0>]
       [0.7 rgb <0.0,0.1,0.8>]
     }
   }
}

light_source {
   <0, 0, 0>
   color rgb <1, 1, 1>
   translate <-30, 30, -30>
}

// ----------------------------------------
// We can confirm the size of our etorus
// by first creating two toruses matching
// the width and height of the etorus
// and then the disc which is an elipse of
// the right size
// ----------------------------------------
torus {
	13
	0.25
	pigment { Red }
}
torus {
	2
	0.25
	pigment { Green }
}
disc {
	0
	y,
	13
	pigment { Yellow }
	scale z*(2/13)
}


// ----------------------------------------
// This is the simple etorus macro. It
// takes a major width radius, major height
// radius and a minor radius
//
// Like the regular torus, the etorus uses
// the X and Z axes as for its major radii
// and the Y axis for it's minor radius
// ----------------------------------------
#macro etorus(w, h, r) sphere_sweep {

     // The factor by which we need to scale
     // a b_spline to get the right size
     #declare s=1.5;

     b_spline
     7,
     <-w*s,  0,    0>, r
     <   0,  0,  h*s>, r
     < w*s,  0,    0>, r
     <   0,  0, -h*s>, r
     <-w*s,  0,    0>, r
     <   0,  0,  h*s>, r
     < w*s,  0,    0>, r

     // tolerance could be a param if you wanted
     tolerance 0.1
}
#end


object {
	etorus(13, 2, 0.25)
	pigment { Blue }
}


Post a reply to this message

From: Mike Williams
Subject: Re: Elliptical Torus?
Date: 10 Feb 2005 04:45:32
Message: <YM4OvDAr0yCCFwAp@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


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 11:19:52
Message: <420cdb28$1@news.povray.org>
"Rick Measham" <nomail@nomail> wrote in message
news:420acbe0@news.povray.org...
> David Cameron wrote:
> > How could I define:
> > #macro elliptical_torus( x_major_radius, z_major_radius, minor_radius)
> >   // which code goes here ?
> > #end
>
> I nervously submit the following. I'm no POV-God but this works for me.
>
> Because of the nature of splines, declaring the four points on the
> compass (plus overlapping to close the shape) we turn it into a perfect
> ellipse. However, because of the nature of POV's b_spline we need to
> scale the elipse by (it seems) 150%.
>
> Anyway, what I'm trying to say is that the following works.
>
> __SCENE__
> // Persistence of Vision Ray Tracer Scene Description File
> // File: etorus.pov
> // Vers: 3.5
> // Desc: Example of an eliptical torus
> // Date: 2005-02-10
> // Auth: Rick Measham
> // Licn: LGPL (http://www.gnu.org/copyleft/lesser.html)
>
> #version 3.5;
>
> #include "colors.inc"
>
> // ----------------------------------------
>
> // Look down rather than rotate all objects :)
> camera {
>    location  <0.0, 50, 0>
>    direction 1.5*z
>    right     x*image_width/image_height
>    look_at   <0.0, 0.0,  0.0>
> }
>
> sky_sphere {
>    pigment {
>      gradient y
>      color_map {
>        [0.0 rgb <0.6,0.7,1.0>]
>        [0.7 rgb <0.0,0.1,0.8>]
>      }
>    }
> }
>
> light_source {
>    <0, 0, 0>
>    color rgb <1, 1, 1>
>    translate <-30, 30, -30>
> }
>
> // ----------------------------------------
> // We can confirm the size of our etorus
> // by first creating two toruses matching
> // the width and height of the etorus
> // and then the disc which is an elipse of
> // the right size
> // ----------------------------------------
> torus {
> 13
> 0.25
> pigment { Red }
> }
> torus {
> 2
> 0.25
> pigment { Green }
> }
> disc {
> 0
> y,
> 13
> pigment { Yellow }
> scale z*(2/13)
> }
>
>
> // ----------------------------------------
> // This is the simple etorus macro. It
> // takes a major width radius, major height
> // radius and a minor radius
> //
> // Like the regular torus, the etorus uses
> // the X and Z axes as for its major radii
> // and the Y axis for it's minor radius
> // ----------------------------------------
> #macro etorus(w, h, r) sphere_sweep {
>
>      // The factor by which we need to scale
>      // a b_spline to get the right size
>      #declare s=1.5;
>
>      b_spline
>      7,
>      <-w*s,  0,    0>, r
>      <   0,  0,  h*s>, r
>      < w*s,  0,    0>, r
>      <   0,  0, -h*s>, r
>      <-w*s,  0,    0>, r
>      <   0,  0,  h*s>, r
>      < w*s,  0,    0>, r
>
>      // tolerance could be a param if you wanted
>      tolerance 0.1
> }
> #end
>
>
> object {
> etorus(13, 2, 0.25)
> pigment { Blue }
> }

Thanks for the reply, Rick.

I tested your macro and the object it produces varies slightly from a true
ellipse. As I need to use the torus in CSG with other elliptical objects (
cylinders, discs etc), this is a problem.

The object produced by the macro matches a true ellipse at the top, bottom,
left and right, but varies slightly from the true ellipse in between.

To demonstrate this you could try the following code. The code tests for an
intersection of the elliptical torus with an elliptical cylinder the size of
the torus "hole".Of course there should be no intersection of the torus was
truely elliptical, but unfortunatly there is a slight intersection.

You can view a pre-rendered image of this file at:
http://www.camnet.myby.co.uk/images/ss_elliptical_torus.jpg

// start of file *************************************
#include "colors.inc"

#declare w = 200;
#declare h = 100;
#declare r = 20;

#macro etorus(w, h, r) sphere_sweep {

     // The factor by which we need to scale
     // a b_spline to get the right size
     #declare s=1.5;

     b_spline
     7,
     <-w*s,  0,    0>, r
     <   0,  0,  h*s>, r
     < w*s,  0,    0>, r
     <   0,  0, -h*s>, r
     <-w*s,  0,    0>, r
     <   0,  0,  h*s>, r
     < w*s,  0,    0>, r

     // tolerance could be a param if you wanted
     tolerance 0.1
}
#end

// define an intersection of an elliptical torus
// with an elliptical cylinder with the
// same radii as the torus "hole"
// there should be no intersection if the
// torus follows a true ellipse
intersection {

  // elleptical cylinder with dimensions
  // of the torus "hole"
  cylinder {
    < 0, 0, -r >, < 0, 0, r>, 1
    scale < w - r, h - r, 1 >
  }

  // the elliptical torus
  object {
    etorus( w, h, r )
    rotate x * 90
  }

  pigment { color Red }
}

camera {
  orthographic
  location <0, 0, -w * 2>
  look_at <0, 0, 0>
}

light_source {
  <0, 0, -w * 2> color White * 1.5
  shadowless
  parallel
}

background { color Blue }

// end of file *************************************


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 11:37:10
Message: <420cdf36$1@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:YM4### [at] econymdemoncouk...
> 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

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 12:46:55
Message: <420cef8f@news.povray.org>
Damn, I spoke too soon. :(
I did a simple CSG test with elliptical_torus before I posted my original
reply, and it seems to work OK.
I have since done further CSG tests which fail.

For instance, this appears to work.

difference {
  // The elliptical torus
  object {
    elliptical_torus( x_major_radius, z_major_radius, minor_radius )
    rotate x * 90
  }
  // The elliptical cylinder
  cylinder {
    < 0, 0, -minor_radius >, < 0, 0, minor_radius / 2 >, 1
    scale < x_major_radius, z_major_radius, 1>
  }
  pigment { color Red }
}

... but this fails

difference {
  // The elliptical cylinder
  cylinder {
    < 0, 0, 0 >, < 0, 0, minor_radius >, 1
    scale < x_major_radius, z_major_radius, 1>
  }
  // The elliptical torus
  object {
    elliptical_torus( x_major_radius, z_major_radius, minor_radius )
    rotate x * 90
  }
  pigment { color Red }
}


Post a reply to this message

From: Mike Williams
Subject: Re: Elliptical Torus?
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

From: Mike Williams
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 13:40:59
Message: <vYJoJHAVvPDCFw+1@econym.demon.co.uk>
Wasn't it David Cameron who wrote:
>Damn, I spoke too soon. :(
>I did a simple CSG test with elliptical_torus before I posted my original
>reply, and it seems to work OK.
>I have since done further CSG tests which fail.

You can only, reliably, perform difference and intersection operations on
objects that have a defined 'inside'. A mesh only has an inside if you use
the "inside_vector" when creating it, which param.inc doesn't do. The mesh
also has to be closed, which is the case for this shape.

I recommend reading the section in the documentation regarding solid mesh
and inside_vector.

To add an inside_vector to a mesh created by param.inc you actually have to
edit "makemesh.inc" and add a line something like
         inside_vector <0, 0, 1>
just before the final "}"

For consistency, in case you want to pass param.inc a filename, change the
line just before the #fclose to
         #write(MeshFile, "\n  }\n  inside_vector <0, 0, 1>\n}")




Alternatively, for these particular operations, you might be able to do
something with these:

#macro inside_half_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,pi/2>,<2*pi,3*pi/2>,  // range changed
       100,20,""
    )
  }
#end


#macro outside_half_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,-pi/2>,<2*pi,pi/2>,   // range changed
       100,20,""
    )
  }
#end


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 14:05:26
Message: <420d01f6@news.povray.org>
> Wasn't it David Cameron who wrote:
> >Damn, I spoke too soon. :(
> >I did a simple CSG test with elliptical_torus before I posted my original
> >reply, and it seems to work OK.
> >I have since done further CSG tests which fail.
>
> You can only, reliably, perform difference and intersection operations on
> objects that have a defined 'inside'. A mesh only has an inside if you use
> the "inside_vector" when creating it, which param.inc doesn't do. The mesh
> also has to be closed, which is the case for this shape.
>
> I recommend reading the section in the documentation regarding solid mesh
> and inside_vector.
>
> To add an inside_vector to a mesh created by param.inc you actually have
to
> edit "makemesh.inc" and add a line something like
>          inside_vector <0, 0, 1>
> just before the final "}"
>
> For consistency, in case you want to pass param.inc a filename, change the
> line just before the #fclose to
>          #write(MeshFile, "\n  }\n  inside_vector <0, 0, 1>\n}")
>
>
>
>
> Alternatively, for these particular operations, you might be able to do
> something with these:
>
> #macro inside_half_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,pi/2>,<2*pi,3*pi/2>,  // range changed
>        100,20,""
>     )
>   }
> #end
>
>
> #macro outside_half_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,-pi/2>,<2*pi,pi/2>,   // range changed
>        100,20,""
>     )
>   }
> #end
>

Thanks again for all your help Mike,
I noticed the comments in the help file concerning CSG, inside_vector and
meshes.Unfortunately I have not worked with meshes or inside_vector before,
so at the moment I have no idea what to specify for the inside_vector. I
will have to do more reading and research to enlighten myself :)
I will report back if I find a solution.

I searched Google archives (newsgroups and net) regarding elliptical torii,
but found very little. I am surprised more people haven't come across a need
for this.

Anyway, I really appreciate your help Mike.

Cheers,
Dave


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 14:13:02
Message: <420d03be$1@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:TIA### [at] econymdemoncouk...
> 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.
>

I would be using several elliptical torii of the same dimensions so this is
great to know.
Now, if only I can solve the "inside_vector" problem.

Thanks again,
Dave


Post a reply to this message

From: Alf Peake
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 16:26:57
Message: <420d2321@news.povray.org>
"David Cameron" wrote:
> Hi All,
> Do any of you know how to produce an elliptical torus?
>

This any use?
http://mathworld.wolfram.com/EllipticTorus.html

Alf


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 17:00:45
Message: <420d2b0d@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:vYJoJHAVvPDCFw+1### [at] econymdemoncouk...
> Wasn't it David Cameron who wrote:
> >Damn, I spoke too soon. :(
> >I did a simple CSG test with elliptical_torus before I posted my original
> >reply, and it seems to work OK.
> >I have since done further CSG tests which fail.
>
> You can only, reliably, perform difference and intersection operations on
> objects that have a defined 'inside'. A mesh only has an inside if you use
> the "inside_vector" when creating it, which param.inc doesn't do. The mesh
> also has to be closed, which is the case for this shape.
>
> I recommend reading the section in the documentation regarding solid mesh
> and inside_vector.
>
> To add an inside_vector to a mesh created by param.inc you actually have
to
> edit "makemesh.inc" and add a line something like
>          inside_vector <0, 0, 1>
> just before the final "}"
>
> For consistency, in case you want to pass param.inc a filename, change the
> line just before the #fclose to
>          #write(MeshFile, "\n  }\n  inside_vector <0, 0, 1>\n}")
>
>
>
>
> Alternatively, for these particular operations, you might be able to do
> something with these:
>
> #macro inside_half_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,pi/2>,<2*pi,3*pi/2>,  // range changed
>        100,20,""
>     )
>   }
> #end
>
>
> #macro outside_half_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,-pi/2>,<2*pi,pi/2>,   // range changed
>        100,20,""
>     )
>   }
> #end
>

I have good news Mike :)
Let me give you a little background info on what I am trying to achieve
first. I am wanting to render a user interface for a program I am
developing. I am writing povray macros for "cookie cutter" type objects to
cut openings in the UI surface for things like push buttons, radio buttons,
check boxes, edit controls etc.

In this particular case I am wanting to to cut an elliptical opening (with
curved edges) in to the UI surface for elliptical buttons etc.

When rendering the "cutter object" using your macro the CSG didn't work
(display correctly).

For view of the "cutter" object from several angles see:
http://www.camnet.myby.co.uk/images/ss_etorus_test.jpg

This uses Rick Measham's sphere_sweep method (earlier in this thread) of
producing the elliptical torus. You will notice the "artifacs" where the
elliptical torus is cut out of the elliptical cylinders, due to that
elliptical torus method deviating from the true ellipse slightly.

A rendering of the "cutter object" from the same angles using your macro
produces the following output:
http://www.camnet.myby.co.uk/images/p_etorus_test.jpg

As you can see this does not display correctly at all, and because of this I
assumed (wrongly) it would not work in it's final usage (as a
difference/cutout from the UI surface) but by chance it does.

See:
http://www.camnet.myby.co.uk/images/e_cutout_test.jpg

So I am very happy at the moment. The only other usage of the elliptical
torus I need at the moment is in the buttons themselves, but this would
involve a union which works fine.

It would be nice to have an elliptical torus which worked in the general
case with all CSG operations, but your macro solves all my current problems.

Thanks a lot Mike,
Dave


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 17:29:33
Message: <420d31cd@news.povray.org>
"Alf Peake" <alf### [at] peake42freeservecouk> wrote in message
news:420d2321@news.povray.org...
> "David Cameron" wrote:
> > Hi All,
> > Do any of you know how to produce an elliptical torus?
> >
>
> This any use?
> http://mathworld.wolfram.com/EllipticTorus.html
>
> Alf
>
>

Thanks for that Alf,
At first glance glance the diagram seems to suggest the ellipse is in the
y-z plane instead of the x-z plane (pov coordinate system), which I am sure
I could find a use for.
If I can figure out how to convert those equations to plug in to a
Parametric (preferably using param.inc), I will play around with it.

Cheers,
Dave


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 17:48:58
Message: <420d365a$1@news.povray.org>
"David Cameron" <nom### [at] tome> wrote in message
news:420d31cd@news.povray.org...
>
> "Alf Peake" <alf### [at] peake42freeservecouk> wrote in message
> news:420d2321@news.povray.org...
> > "David Cameron" wrote:
> > > Hi All,
> > > Do any of you know how to produce an elliptical torus?
> > >
> >
> > This any use?
> > http://mathworld.wolfram.com/EllipticTorus.html
> >
> > Alf
> >
> >
>
> Thanks for that Alf,
> At first glance glance the diagram seems to suggest the ellipse is in the
> y-z plane instead of the x-z plane (pov coordinate system), which I am
sure
> I could find a use for.
> If I can figure out how to convert those equations to plug in to a
> Parametric (preferably using param.inc), I will play around with it.

Sorry, that was probably unclear Alf,
I should have stated that object (at first glance appears to me) is
eliptical around the minor radii and not the major radii.
Major and minor radius in terms of povray torus syntax.

torus { major_radius, minor_radius }

The macro I was looking for is
#macro elliptical_torus( x_major_radius, z_major_radius, minor_radius)

I think that torus at mathworld is equivolent to:
#macro elliptical_torus( major_radius, x_minor_radius, y_minor_radius )
when orientated like a pov torus (x z plane)

But like I said Alf, I am sure I could find a use for it.

Thanks again,
Dave


Post a reply to this message

From: Mike Williams
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 18:14:15
Message: <vUMoaCAAuTDCFweL@econym.demon.co.uk>
Wasn't it David Cameron who wrote:
>
>It would be nice to have an elliptical torus which worked in the general
>case with all CSG operations, but your macro solves all my current problems.

The real parametric version I provided should work in all cases. It's
only the quick approximation that uses a mesh.


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Mike Williams
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 18:29:28
Message: <TNBc$BAJ$TDCFw4O@econym.demon.co.uk>
Wasn't it David Cameron who wrote:
>
>"David Cameron" <nom### [at] tome> wrote in message
>news:420d31cd@news.povray.org...
>>
>> "Alf Peake" <alf### [at] peake42freeservecouk> wrote in message
>> news:420d2321@news.povray.org...
>> > "David Cameron" wrote:
>> > > Hi All,
>> > > Do any of you know how to produce an elliptical torus?
>> > >
>> >
>> > This any use?
>> > http://mathworld.wolfram.com/EllipticTorus.html
>> >
>> > Alf
>> >
>> >
>>
>> Thanks for that Alf,
>> At first glance glance the diagram seems to suggest the ellipse is in the
>> y-z plane instead of the x-z plane (pov coordinate system), which I am
>sure
>> I could find a use for.
>> If I can figure out how to convert those equations to plug in to a
>> Parametric (preferably using param.inc), I will play around with it.
>
>Sorry, that was probably unclear Alf,
>I should have stated that object (at first glance appears to me) is
>eliptical around the minor radii and not the major radii.
>Major and minor radius in terms of povray torus syntax.
>
>torus { major_radius, minor_radius }
>
>The macro I was looking for is
>#macro elliptical_torus( x_major_radius, z_major_radius, minor_radius)
>
>I think that torus at mathworld is equivolent to:
>#macro elliptical_torus( major_radius, x_minor_radius, y_minor_radius )
>when orientated like a pov torus (x z plane)
>
>But like I said Alf, I am sure I could find a use for it.
>

What they have on that mathworld site is easy. Using their "a", "b", "c"
parameters it's just

        torus {a,b scale <1,c/b,1>}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: David Cameron
Subject: Re: Elliptical Torus?
Date: 11 Feb 2005 19:21:54
Message: <420d4c22@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:vUM### [at] econymdemoncouk...
> Wasn't it David Cameron who wrote:
> >
> >It would be nice to have an elliptical torus which worked in the general
> >case with all CSG operations, but your macro solves all my current
problems.
>
> The real parametric version I provided should work in all cases. It's
> only the quick approximation that uses a mesh.
>

I seem to have problems with the real parametic version you provided Mike.
I used it cut and pasted from your original post.

When I rendered the elliptical torus itself, I got this result:
http://www.camnet.myby.co.uk/images/eleptical_torus_test2.jpg

As you can see the torus seems to be "breaking up" in places.

When rendering my "cutter object" in several orientations, I got this
result:
http://www.camnet.myby.co.uk/images/p_etorus_test2.jpg

Similar results to the "param.inc mesh version".

When I render my "cutout from the UI surface", I get this result:
http://www.camnet.myby.co.uk/images/e_cutout_test2.jpg

As you can see, this introduces a line around the cutout and some "spotting"
near the inner part of the cutout.

Dave


Post a reply to this message

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