POV-Ray : Newsgroups : povray.binaries.images : Not a Sphere (91K) : Re: Not a Sphere (91K) Server Time
20 Nov 2024 06:27:25 EST (-0500)
  Re: Not a Sphere (91K)  
From: Tor Olav Kristensen
Date: 14 Oct 2001 18:07:11
Message: <3BCA0C4D.3FA79EFC@hotmail.com>
"Arie L. Stavchansky" wrote:
> 
> Hi there,
> 
> I know it is alot to ask, but can you please explain this code and algorithm
> in English?  I don't have a very strong math background and would like to
> understand how it is done.  This is amazing stuff!

Hello Arie.

Sorry for not replying earlier.

I have rewritten some of the code a
little. It now uses degrees instead
of radians. And I use spheres this
time, because spheres have a simpler
syntax than boxes.

I've also split up the two while
loops so that you can see the effect
of each of them separately.


First we'll rotate a sphere, put one
unit above origo, around the x-axis
6 degrees at a time until it ends up
one unit below origo. (The y-axis is
pointing "upwards".)

#declare Step = 360/60;

#declare Cx = 0;
#while(Cx < 180)
  sphere {
    <0, 1, 0>, 0.06
    rotate Cx*x
    texture { T_Gold_3C }
  }
  #declare Cx = Cx + Step;
#end // while


This code will rotate a sphere, put
one unit out on the positive part
of the x-axis all the way around the
y-axis 6 degrees at the time.

#declare Step = 360/60;

#declare Cy = 0;
#while(Cy < 360)
  sphere {
    <1, 0, 0>, 0.06
    rotate Cy*y
    texture { T_Gold_1A }
  }
  #declare Cy = Cy + Step;
#end // while


Then we'll combine these two loops so
that one loop is inside the other.

Now, for each step the sphere is
rotated around the x-axis, it is also
taken all the way around the y-axis.

#declare Step = 360/60;

#declare Cx = 0;
#while(Cx < 180)
  #declare Cy = 0;
  #while(Cy < 360)
    sphere {
      <0, 1, 0>, 0.04
      rotate Cx*x
      rotate Cy*y
      texture { T_Gold_2B }
    }
    #declare Cy = Cy + Step;
  #end // while
  #declare Cx = Cx + Step;
#end // while


You may also notice that it is 
possible to switch places for the
two while loops. (But this way around
it is more difficult to imagine what
is really going on.    =)

#declare Step = 360/60;

#declare Cy = 0;
#while(Cy < 360)
  #declare Cx = 0;
  #while(Cx < 180)
    sphere {
      <0, 1, 0>, 0.04
      rotate Cx*x
      rotate Cy*y
      texture { T_Gold_2B }
    }
    #declare Cx = Cx + Step;
  #end // while
  #declare Cy = Cy + Step;
#end // while


I hope this helped you on the way to
understand better what's happening.

And if you have any further questions,
please feel free to ask.


Tor Olav


Btw.:
Remember to put something similar to
this at the beginning of each of my
examples above:


#version 3.1;  // Or e.g. #version 3.5

#include "colors.inc"
#include "golds.inc"

light_source { <2, 1, 2> color White }

background { color Blue/2 }

camera {
  location <1, 1, 3>
  look_at <0, 0, 0>
}


Post a reply to this message

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