POV-Ray : Newsgroups : povray.general : Elliptical toroids--another take : Re: Elliptical toroids--another take Server Time
30 Jul 2024 16:15:51 EDT (-0400)
  Re: Elliptical toroids--another take  
From: Nicolas George
Date: 21 Oct 2008 13:17:50
Message: <48fe0ebe$1@news.povray.org>
"Cousin Ricky"  wrote in message
<web.48fdffd33cf15dac85de7b680@news.povray.org>:
> x and z are your standard coordinates in 3-space.
> 
> d is the difference between the semimajor and semiminor axes, with the semimajor
> assumed, for the time being, to be in the z-direction.
> 
> t is the difference between the z-coordinates of corresponding points on the
> oblong torus and a circular torus, such that the major radius of the circular
> torus equals the semiminor axis of the central ellipse of the oblong torus.

That seems to be overly complicated.

I tried the following, much simper approach:

Let M be a point in space.
Let P be the projection of M on the (x,y) plane.
Let Q be the intersection of segment [OP] with the ellipsis.

Then M is on the torus if and only of MQ = r, where r is the minor radius of
the torus (which is not the minor radius of the core ellipsis).

MQ can be computed in the triangle QPM:
PM = z
QP = OP - OQ



where a and b are the radius of the core ellipsis.

Fiddling around with the equations to get rid of the square root, I get:



The following macro implements it, and looks pretty much like an elliptic
torus:

#macro Ellipsis_torus(a, b, r)
  isosurface {
    function { pow((b*b*x*x + a*a*y*y) * (x*x + y*y + z*z - r*r) +
      a*a*b*b * (x*x + y*y), 2) -
      4 * pow(a * b * (x*x + y*y), 2) * (b*b*x*x + a*a*y*y) }
    contained_by { box { <-a - r, -b - r, -r>, <a + r, b + r, r> } }
    max_gradient 100000000000
  }
#end

The max_gradient was adjusted according to the warnings, in the particular
case Ellipsis_torus(8, 5, 1).

This equation looks pretty much like a eighth order polynomial. If you have
enough courage, you can expand it and find the 165 parameters needed for the
poly primitive, this would probably be faster than isosurface, and there
would be no need for the max_gradient.


Post a reply to this message

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