// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2017-05-07 20:10:09 by stolfilocal

#include "colors.inc"
#include "shapes.inc"

#declare component_color =
  texture {
    pigment { color rgb <0.2, 0.2, 0.2> }
  }

#macro Circle(BeadCount, Radius, CenterX, CenterY, CenterZ)
  #local Theta = 0;

  #for (Bead, 1, BeadCount, 1)
    #local X = CenterX + Radius * cos(Theta);
    #local Y = CenterY + Radius * sin(Theta);

    #declare Theta = Theta + (2 * pi)/BeadCount;

    sphere {
      <X, Y, CenterZ>,
      0.4
      texture { component_color }
    }
  #end
#end

#macro Square(BeadCount, Side, CenterX, CenterY, CenterZ)
  #local X0 = CenterX - Side/2;
  #local Y0 = CenterY - Side/2;
  #local X1 = CenterX + Side/2;
  #local Y1 = CenterY + Side/2;

  #local BeadsPerSide = BeadCount / 4;
  #local X = X0;
  #local Y = Y0;

  #for (Bead, 1, BeadsPerSide, 1)
    sphere {
      <X, Y, CenterZ>,
      0.4
      texture { component_color }
    }

    #declare X = X + (X1 - X0)/BeadsPerSide;
  #end

  #declare X = X1;
  #declare Y = Y0;

  #for (Bead, 1, BeadsPerSide, 1)
    sphere {
      <X, Y, CenterZ>,
      0.4
      texture { component_color }
    }

    #declare Y = Y + (Y1 - Y0)/BeadsPerSide;
  #end

  #declare X = X1;
  #declare Y = Y1;

  #for (Bead, 1, BeadsPerSide, 1)
    sphere {
      <X, Y, CenterZ>,
      0.4
      texture { component_color }
    }

    #declare X = X - (X1 - X0)/BeadsPerSide;
  #end

  #declare X = X0;
  #declare Y = Y1;

  #for (Bead, 1, BeadsPerSide, 1)
    sphere {
      <X, Y, CenterZ>,
      0.4
      texture { component_color }
    }

    #declare Y = Y - (Y1 - Y0)/BeadsPerSide;
  #end
#end

background { color rgb <0.7, 0.7, 0.7> }

camera {
  location <2, 4, 5>
  look_at <0, 1, 2>
}

light_source { <2, 4, -3> color White }

Circle(100, 2.5, -4, -5.5, 0)
Square(500, 3, 0, 0, 0)