POV-Ray : Newsgroups : povray.newusers : Elliptical Torus : Re: Elliptical Torus Server Time
29 Jul 2024 16:33:32 EDT (-0400)
  Re: Elliptical Torus  
From: Sebastian H 
Date: 4 Mar 2006 12:23:54
Message: <4409cd2a@news.povray.org>
tgl wrote:
> "tgl" <aub### [at] sympaticoca> wrote:
> 
>>Hello All
>>Is it possible to create an elliptical torus with a varying major diameter
>>and a constant minor diameter?
>>  Thanx,
>>  tgl
> 

I found an isosurface sullution but it's
ugly and slow and I'm not sure whether it
is mathematical "correct" description of
the surface you're looking for. Anyhow it
looks quite like an elliptical torus.

Starting with the two focal point implicit
definition of an ellipse one can simply
alter the ellipse radii with y. The max gradient
explodes but it must be somewhere above the surface
since there are no black spots with a max gradient around
18.

Here's the code snippet.

/*
  * Isosurface ellipsoid torus
  */
#declare Torus_RmajX = 8.0;
#declare Torus_RmajZ = 3.0;
#declare Torus_Rmin = 1.0;

#declare bbox_min = <-(Torus_RmajX + Torus_Rmin), -Torus_Rmin, 
-(Torus_RmajZ + Torus_Rmin)>;
#declare bbox_max = < (Torus_RmajX + Torus_Rmin),  Torus_Rmin, 
(Torus_RmajZ + Torus_Rmin)>;

// Function for focal length with given major and minor radius
// Major radius is along x-axis, minor along z-axis
// This function is abused in f_iso_ellipsoid_torus where
// the same term is required
#declare f_fl = function(rx, rz) { sqrt(max(rx*rx - rz*rz, 0)) }
// The max function above is neccessary to avoid negative square
// roots

// Function for an ellipse in the xz plane
#declare f_iso_ellipsoid =
   function(x,y,z,rx,rz) {
     f_r(x+f_fl(rx,rz),0,z) + f_r(x-f_fl(rx,rz),0,z) - 2*rx
   }

// Use of ellipse function to create inner and outer torus
// halfes which are merged with max()
#declare f_iso_ellipsoid_torus =
   function(x,y,z) {
     max (
 
f_iso_ellipsoid(x,y,z,Torus_RmajX+f_fl(Torus_Rmin,y),Torus_RmajZ+f_fl(Torus_Rmin,y)),
 
-f_iso_ellipsoid(x,y,z,Torus_RmajX-f_fl(Torus_Rmin,y),Torus_RmajZ-f_fl(Torus_Rmin,y))
     )
   }

// The actual object
#declare Iso_Ellipsoid_Torus =
   isosurface {
     function { f_iso_ellipsoid_torus(x,y,z) }
     contained_by { box { bbox_min, bbox_max } }  // container shape
     max_gradient 18                      // maximum gradient the 
function can have [1.1]
   }

End of code snippet.

I looked around in the internet for a function
that returns the distance to an ellipse which
seems to be an unsolvable problem. At least
this is what some papers claimed.
Somwhere the problem was reduced to a
quartic which can be solved somehow iirc
so the above statement would be wrong.
I did not follow it any further but it
is an interesting problem. Maybe I'll
give it another try some day...

Regards,
Sebastian


Post a reply to this message

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