POV-Ray : Newsgroups : povray.general : Spiral around a sphere. How? Server Time
7 Nov 2024 15:36:37 EST (-0500)
  Spiral around a sphere. How? (Message 1 to 3 of 3)  
From: Patrick Dugan
Subject: Spiral around a sphere. How?
Date: 3 Feb 2002 18:43:48
Message: <3c5dcb34@news.povray.org>
I'm requesting some help for creating a small object.  I want to basically
wrap a rounded spiral around a sphere.

I have placed an example picture of what I'm trying to accomplish on the
povray.binaries.images.

The image I posted shows a roundish spiral snaking around a sphere.

How can I make something like that?  I'm no math whiz so I'm not sure what I
could use to make something like that.  Can you use an isosurface of some
sort or would it be a spline?

Basically I have no clue.  Any helpful input would be appreciated!


Patrick Dugan


Post a reply to this message

From: Slime
Subject: Re: Spiral around a sphere. How?
Date: 4 Feb 2002 01:05:26
Message: <3c5e24a6$1@news.povray.org>
> How can I make something like that?  I'm no math whiz so I'm not sure what
I
> could use to make something like that.  Can you use an isosurface of some
> sort or would it be a spline?

Well, I assume a sphere_sweep would be easiest. Let's create some basic
rules for it. The y value must go up steadily:

sphere_sweep {
 catmul_rom_spline // check spelling on this
 #declare numpoints = 20; // whatever
 numpoints
 #declare pointnum = 0;
 #while (pointnum < numpoints)
  , pointnum/(numpoints-1) // the value, from zero to one, that this point
on the spline should be
  , <???, pointnum/(numpoints-1)*2-1, ???>, radius
  #declare pointnum = pointnum + 1;
 #end
}

The pointnum/(numpoints-1)*2-1 is the y value, which will steadily increase
from -1 to 1. Now, as we go around the sphere, the X and Z values will be
sine and cosine times the radius of the cross section of the sphere at the
current y value. So...

#declare numrotations = 3;
sphere_sweep {
 catmul_rom_spline // check spelling on this
 #declare numpoints = 20; // whatever
 numpoints
 #declare pointnum = 0;
 #while (pointnum < numpoints)
  , <cos(pointnum/(numpoints-1)*numrotations*2*pi),
     pointnum/(numpoints-1)*2-1,
     sin(pointnum/(numpoints-1)*numrotations*2*pi)>, radius
  #declare pointnum = pointnum + 1;
 #end
}

Now, that will wrap it around a cylinder. In order to wrap it around a
sphere, we have to multiply the x and z values by the radius of the cross
section of the sphere at the current y value. Since the equation of a circle
of radius 1 is y=sqrt(1-x^2)...

#declare numrotations = 3;
sphere_sweep {
 catmul_rom_spline // check spelling on this
 #declare numpoints = 20; // whatever
 numpoints
 #declare pointnum = 0;
 #while (pointnum < numpoints)
  #declare cury = pointnum/(numpoints-1)*2-1
  , <cos(pointnum/(numpoints-1)*numrotations*2*pi) * sqrt(1-cury^2),
     cury,
     sin(pointnum/(numpoints-1)*numrotations*2*pi) * sqrt(1-cury^2)>, radius
  #declare pointnum = pointnum + 1;
 #end
}

That should do it, I think. All this code is untested. Think it all through
until you understand it; copying code won't get you anywhere the next time
you're faced with a problem to solve.

Oh, one more thing. If you want the radius to grow and then shrink, you'll
have to do that as some function of cury, such as radius = 1-cury^2.

- Slime
[ http://www.slimeland.com/ ]
[ http://www.slimeland.com/images/ ]


Post a reply to this message

From: Patrick Dugan
Subject: Re: Spiral around a sphere. How?
Date: 4 Feb 2002 09:09:15
Message: <3c5e960b$1@news.povray.org>
Thanks!!


"Slime" <noo### [at] hotmailcom> wrote in message
news:3c5e24a6$1@news.povray.org...
> > How can I make something like that?  I'm no math whiz so I'm not sure
what
> I
> > could use to make something like that.  Can you use an isosurface of
some
> > sort or would it be a spline?
>
> Well, I assume a sphere_sweep would be easiest. Let's create some basic
> rules for it. The y value must go up steadily:
>
> sphere_sweep {
>  catmul_rom_spline // check spelling on this
>  #declare numpoints = 20; // whatever
>  numpoints
>  #declare pointnum = 0;
>  #while (pointnum < numpoints)
>   , pointnum/(numpoints-1) // the value, from zero to one, that this point
> on the spline should be
>   , <???, pointnum/(numpoints-1)*2-1, ???>, radius
>   #declare pointnum = pointnum + 1;
>  #end
> }
>
> The pointnum/(numpoints-1)*2-1 is the y value, which will steadily
increase
> from -1 to 1. Now, as we go around the sphere, the X and Z values will be
> sine and cosine times the radius of the cross section of the sphere at the
> current y value. So...
>
> #declare numrotations = 3;
> sphere_sweep {
>  catmul_rom_spline // check spelling on this
>  #declare numpoints = 20; // whatever
>  numpoints
>  #declare pointnum = 0;
>  #while (pointnum < numpoints)
>   , <cos(pointnum/(numpoints-1)*numrotations*2*pi),
>      pointnum/(numpoints-1)*2-1,
>      sin(pointnum/(numpoints-1)*numrotations*2*pi)>, radius
>   #declare pointnum = pointnum + 1;
>  #end
> }
>
> Now, that will wrap it around a cylinder. In order to wrap it around a
> sphere, we have to multiply the x and z values by the radius of the cross
> section of the sphere at the current y value. Since the equation of a
circle
> of radius 1 is y=sqrt(1-x^2)...
>
> #declare numrotations = 3;
> sphere_sweep {
>  catmul_rom_spline // check spelling on this
>  #declare numpoints = 20; // whatever
>  numpoints
>  #declare pointnum = 0;
>  #while (pointnum < numpoints)
>   #declare cury = pointnum/(numpoints-1)*2-1
>   , <cos(pointnum/(numpoints-1)*numrotations*2*pi) * sqrt(1-cury^2),
>      cury,
>      sin(pointnum/(numpoints-1)*numrotations*2*pi) * sqrt(1-cury^2)>,
radius
>   #declare pointnum = pointnum + 1;
>  #end
> }
>
> That should do it, I think. All this code is untested. Think it all
through
> until you understand it; copying code won't get you anywhere the next time
> you're faced with a problem to solve.
>
> Oh, one more thing. If you want the radius to grow and then shrink, you'll
> have to do that as some function of cury, such as radius = 1-cury^2.
>
> - Slime
> [ http://www.slimeland.com/ ]
> [ http://www.slimeland.com/images/ ]
>
>


Post a reply to this message

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