POV-Ray : Newsgroups : povray.general : Even distribution on a sphere : Re: Even distribution on a sphere Server Time
5 Aug 2024 14:18:35 EDT (-0400)
  Re: Even distribution on a sphere  
From: Michael Andrews
Date: 18 Oct 2002 11:37:09
Message: <3db02aa5$1@news.povray.org>
hughes, b. wrote:
> Maybe this one from Mike Andrews last year might make some sense. Sure is
> confusing to me though.
> 
> news://povray.org/3B97457B.26C14AE4@reading.ac.uk

Hmm, that has the old calculation for the latitude - it was up to 2% off 
from the analytic function. I'll put in the updated version of the macro.

As for confusing ... well, maybe. The idea is to change the rate that 
you change the latitude while rotating about the y-axis at a constant rate.

The best function for the latitude is PH=180*(acos(1-2*F)/pi) where PH 
goes from 0 to 180 degrees as F goes from 0 to 1. This function covers 
the same area on the sphere surface for equal increases in F.

The best value to add to the rotation is the Golden Ratio, 
Phi=(sqrt(5)-1)/2, of the circle - so TH = mod(TH + 360*Phi, 360).

Hope this clears things up a bit.

Bye for now,
	Mike Andrews.

#macro Pack_Sphere (nSph, bigRad, smallRad, Offset, useSepTex, resetTh)
   #local Phi = (sqrt(5)-1)/2;

   #if (resetTh) #declare TH = 0; #end

   #local maxC = nSph;

   #if (smallRad < 0)
     #local Rad2 = -smallRad*2*bigRad/sqrt(maxC);
   #else
     #local Rad2 = smallRad;
   #end

   #local Rad1 = bigRad + Offset*Rad2;

   union {
     #local Count = 0; #while (Count < maxC)
       #local F = Count/(maxC-1);

       // the analytic function!
       #local PH = 180*(acos(1-2*F)/pi);

       #local P = vrotate(Rad1*y, <PH, TH, 0>);

       box { -Rad2, Rad2 translate P #if (useSepTex) sep_tex(TH, PH) #end }
       #declare TH = mod(TH + 360*Phi, 360);
     #local Count = Count + 1; #end
   }
#end


Post a reply to this message

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