POV-Ray : Newsgroups : povray.advanced-users : Creating Spheres of Triangles : Re: Creating Spheres of Triangles Server Time
4 Nov 2024 19:23:03 EST (-0500)
  Re: Creating Spheres of Triangles  
From: Nieminen Mika
Date: 1 Jul 1999 05:28:24
Message: <377b34b8@news.povray.org>
Lars W. <lar### [at] snafude> wrote:
: I wan't to construct an Sphere out of triangles ,( i know the standard
: POV-Sphere is faster and better and
: so on, but i need a trianglesphere ), does anybody know of resources, or has
: an tutorial by him self
: for doing that. it should be possible to say, how complex the sphere should
: be, and it should
: NOT look like an globe, best would be an sphere out of evenly sized
: triangles.

  Distributing objects evenly on the surface of a sphere is a non-trivial
task.
  If making a earth-looking globe (with latitude and longitude lines) is
enough, that's pretty easy with povray (you need some math, though).
Something like this:

#declare Radius=1;
#declare Size1=20;
#declare Size2=10;

mesh
{ #declare Ind2=0;
  #while(Ind2<Size2)
    #declare Ang2_1=pi*Ind2/Size2;
    #declare Ang2_2=pi*(Ind2+1)/Size2;
    #declare Ind1=0;
    #while(Ind1<Size1)
      #declare Ang1_1=2*pi*Ind1/Size1;
      #declare Ang1_2=2*pi*(Ind1+1)/Size1;
      #declare P1=<Radius*(sin(Ang1_1)*sin(Ang2_1)),
                   Radius*cos(Ang2_1),
                   Radius*(cos(Ang1_1)*sin(Ang2_1))>;
      #declare P2=<Radius*(sin(Ang1_2)*sin(Ang2_1)),
                   Radius*cos(Ang2_1),
                   Radius*(cos(Ang1_2)*sin(Ang2_1))>;
      #declare P3=<Radius*(sin(Ang1_2)*sin(Ang2_2)),
                   Radius*cos(Ang2_2),
                   Radius*(cos(Ang1_2)*sin(Ang2_2))>;
      #declare P4=<Radius*(sin(Ang1_1)*sin(Ang2_2)),
                   Radius*cos(Ang2_2),
                   Radius*(cos(Ang1_1)*sin(Ang2_2))>;
      triangle { P1,P2,P3 }
      triangle { P1,P3,P4 }
      #declare Ind1=Ind1+1;
    #end
    #declare Ind2=Ind2+1;
  #end
}

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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