POV-Ray : Newsgroups : povray.text.scene-files : Source code for "Almost Sphere Spirals" : Re: Source code for "Almost Sphere Spirals" Server Time
3 Jul 2024 02:24:22 EDT (-0400)
  Re: Source code for "Almost Sphere Spirals"  
From: R  Suzuki
Date: 28 Jan 2002 04:25:12
Message: <3c5518f8@news.povray.org>
"Tor Olav Kristensen"  wrote in message
>At 24. January 2002 I posted an image to povray.binaries.images.
>Below is the source for it.

Thanks.  That is interesting. 

>Note that when I rendered this image, a small defect appeared at the
>"south pole" of the sphere. I'm not sure what causes this. 

I see.  I've encountered the same problem in the carpet project.  
That is due to 'mod' function.  The first parameter of 'mod' function 
should be positive in such cases.  
So, the below macro will work as expected.

R. Suzuki

------------------------------
#macro SphereSpiralsFunction(Rmaj, Rmin, PhiFn, NrOfBands, GapRatio)

  #local TwoPi = 2*pi;
  #local DivAngle = TwoPi/NrOfBands;
  #local GapAngle = DivAngle*GapRatio;
  #local HalfGapAngle = GapAngle/2;

  function {
    select(
      mod(
        atan2(z, x) - PhiFn(x, y, z) +
        select(atan2(z, x) - PhiFn(x, y, z), TwoPi, 0) +TwoPi,
        DivAngle
      ) - GapAngle,

      select(
        mod(
          atan2(z, x) - PhiFn(x, y, z) +
          select(atan2(z, x) - PhiFn(x, y, z), TwoPi, 0) +TwoPi,
          DivAngle
        ) - HalfGapAngle,

        f_sphere(
          x - Rmaj*f_r(x, 0, z)/(Nothing + f_r(x, y, z))*
          cos(
            atan2(z, x) -
            mod(
              atan2(z, x) - PhiFn(x, y, z) +
              select(atan2(z, x) - PhiFn(x, y, z), TwoPi, 0) +TwoPi,
              DivAngle
            )
          ),

          y - Rmaj*y/(Nothing + f_r(x, y, z)),

          z - Rmaj*f_r(x, 0, z)/(Nothing + f_r(x, y, z))*
          sin(
            atan2(z, x) -
            mod(
              atan2(z, x) - PhiFn(x, y, z) +
              select(atan2(z, x) - PhiFn(x, y, z), TwoPi, 0) +TwoPi,
              DivAngle
            )
          ),

          Rmin
        ),
        
        f_sphere(
          x - Rmaj*f_r(x, 0, z)/(Nothing + f_r(x, y, z))*
          cos(
            atan2(z, x) -
            mod(
              atan2(z, x) - PhiFn(x, y, z) +
              select(atan2(z, x) - PhiFn(x, y, z), TwoPi, 0) +TwoPi,
              DivAngle
            ) + GapAngle
          ),

          y - Rmaj*y/(Nothing + f_r(x, y, z)),

          z - Rmaj*f_r(x, 0, z)/(Nothing + f_r(x, y, z))*
          sin(
            atan2(z, x) -
            mod(
              atan2(z, x) - PhiFn(x, y, z) +
              select(atan2(z, x) - PhiFn(x, y, z), TwoPi, 0) +TwoPi,
              DivAngle
            ) + GapAngle
          ),

          Rmin
        )
      ),

      abs(f_sphere(x, y, z, Rmaj)) - Rmin
    )
  }

#end // macro SphereSpiralsFunction


Post a reply to this message

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