POV-Ray : Newsgroups : povray.general : Spherical Sweep Along a Parametric Curve Server Time
5 Nov 2024 15:54:25 EST (-0500)
  Spherical Sweep Along a Parametric Curve (Message 1 to 3 of 3)  
From: Randall Sawyer
Subject: Spherical Sweep Along a Parametric Curve
Date: 25 Nov 2006 02:25:00
Message: <web.4567ebe377f8a7548c37caaf0@news.povray.org>
Spherical Sweep Along a Parametric Curve

Specific:
I recently needed to create an elliptical cylinder with a rounded (circular)
edge.  To do this, I wrote the following macro for generating a parametric
surface which I call a "torlipse" (from "torus" and "ellipse").  The
torlipse is a spherical sweep of radius 'r' along the parameterized ellipse
e(u) = < a * cos(u), 0, b * sin(u) >.

//  Last updated: 2006.11.24
//  Description: Macro which generates a spherical sweep of
//  radius 'r' along an ellipse in the x-z plane with
//  semi-radii of 'a' and 'b'. The parameters 'th0' and
//  'th1' allow the possibility of a sweep along an elliptical
//  arc.  Use th0 = 0 and th1 = 2*pi for a complete sweep.

#macro torlipse( a, b, r, th0, th1 )
    parametric {
        function { cos(u) * ( a + cos(v)*r*b / sqrt( pow(b*cos(u), 2) +
pow(a*sin(u), 2) ) ) },
        function { -r*sin(v) },
        function { sin(u) * ( b + cos(v)*r*a / sqrt( pow(b*cos(u), 2) +
pow(a*sin(u), 2) ) ) }
        <th0, 0>, <th1, 2*pi>

        contained_by { box { 1.1 * <-a-r, -r, -b-r>, 1.1 * <a+r, r, b+r> } }
        precompute 10 x,y,z
        accuracy 0.000001*r
   }
#end

To no avail, as of yet, I continue to determine the possibility of
expressing this surface as an isosurface.

General:
I see the potential need to render a spherical sweep along any
parameterizable curve in 3-space.  I cannot imagine that I am the first to
address this need.

So, my questions to the POVRay community are

    1)  Has someone already established a good generalized method for
rendering spherical sweeps along parameterizable curves?

    2)  Is it possible to express a spherical sweep along any
parameterizable curve into an isosurface expression? (Obviously, it is
possible for special cases: e.g. line segment -> cylinder and circle ->
torus.)

    3)  Would it be beneficial to include a built-in function for creating
spherical sweeps along parametric curves in future releases of POV
Raytracer?

If someone else has already done the work, then I would like to save myself
the time and effort.  On the other hand, if it turns out that this is a new
or pending 'todo', then I wish to contribute my efforts to the POVRay
community.

I will appreciate any response.

Yours,
Randall Sawyer


Post a reply to this message

From: Mike Williams
Subject: Re: Spherical Sweep Along a Parametric Curve
Date: 25 Nov 2006 06:43:17
Message: <qVd5KOAhoCaFFwau@econym.demon.co.uk>
Wasn't it Randall Sawyer who wrote:
>Spherical Sweep Along a Parametric Curve

Have you considered using a sphere_sweep?

#declare A=2;
#declare B=1.5;
#declare R=0.2;

#declare fx = function(x) { A*sin(x)}
#declare fy = function(y) {0}
#declare fz = function(z) { B*cos(z)}

#declare Steps = 20;

sphere_sweep {
  b_spline
  Steps+3,
  #local i=0;
  #while (i<Steps+3)
    #local a = 2*pi*i/Steps;
    <fx(a), fy(a), fz(a)>, R
    #local i=i+1;
  #end
  //tolerance 1.0e-4
  pigment {rgb <1,1,0>}
}

If you use a high value for Steps then you may need to use a tollerance
setting to avoid ugly artefacts.

The "Steps+3" bit allows for the additional control points required for
b_spline or cubic_spline so that you get a closed loop. If using
linear_spline then you only need Steps+1, but you also need a very high
value of Steps to make it look smooth, and then you get awful artefacts
that can't be got rid of by setting tolerance.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Randall Sawyer
Subject: Re: Spherical Sweep Along a Parametric Curve
Date: 25 Nov 2006 16:10:00
Message: <web.4568b07cd669f4188c37caaf0@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
> Wasn't it Randall Sawyer who wrote:
> >Spherical Sweep Along a Parametric Curve
>
> Have you considered using a sphere_sweep?

Thank you.  That works well.

With a background in mathematics, I was looking for an explicit solution
based on differential geometry.  But, I must concede that in a pixelized
environment, approximations such as splines work just fine.

Your solution renders a lot faster too.

-Randall


Post a reply to this message

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