#include "eixos.inc"
#include "transforms.inc"
// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2020-09-30 19:57:13 by jstolfi

// ======================================================================
// CORES E TEXTURAS

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

#declare tx_vertice =
  texture{
    pigment{ color rgb < 0.585, 0.292, 0 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_tubo =
  texture{
    pigment{ color rgb < 0.01, 1, 0.12 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare vertice_1 = union { 
    sphere {
        <0, 0, 0>, 1
    }
    cylinder {
      <0, 2, 0>, <0, -2, 0>, 0.5
    }
    texture { tx_vertice }
  }

#macro vertice_2(cx, cy, cz) 
  box {
      <cx-0.5, cy-0.5, cz-0.5>, <cx+0.5, cy+0.5, cz+0.5> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
      texture { tx_vertice }
  }
#end

#macro vertice_3(cx, cy, cz) 
  union {
    polygon { 5, <cx+0.5, cy+0.5, cz-0.5>, <cx-0.5, cy+0.5, cz-0.5>, <cx-0.5, cy-0.5, cz-0.5>, <cx+0.5, cy-0.5, cz-0.5>, <cx+0.5, cy+0.5, cz-0.5> }
    polygon { 4, <cx+0.5, cy+0.5, cz-0.5>, <cx-0.5, cy+0.5, cz-0.5>, <cx, cy, cz+0.5>, <cx+0.5, cy+0.5, cz-0.5> }
    polygon { 4, <cx-0.5, cy+0.5, cz-0.5>, <cx-0.5, cy-0.5, cz-0.5>, <cx, cy, cz+0.5>, <cx-0.5, cy+0.5, cz-0.5> }
    polygon { 4, <cx-0.5, cy-0.5, cz-0.5>, <cx+0.5, cy-0.5, cz-0.5>, <cx, cy, cz+0.5>, <cx-0.5, cy-0.5, cz-0.5> }
    polygon { 4, <cx+0.5, cy-0.5, cz-0.5>, <cx+0.5, cy+0.5, cz-0.5>, <cx, cy, cz+0.5>, <cx+0.5, cy-0.5, cz-0.5> }
    texture { tx_vertice }
  }
#end

#declare vertice_4 = cylinder {
    <0,0,-0.5>, <0, 0, 0.5>, 1 // center of one end, center of other end, radius
    texture { tx_vertice }    
}

#macro interpola1(ti, t0, v0, t1, v1)
  #local ss = (ti-t0)/(t1-t0);
  #local vv = (1-ss)*v0 + ss*v1;
  vv
#end

#macro interpola3(ti, ta, tb, v0, v1, v2, v3)
  #local v01 = interpola1(ti, ta, v0, tb, v1);
  #local v12 = interpola1(ti, ta, v1, tb, v2);
  #local v23 = interpola1(ti, ta, v2, tb, v3);
  #local v012 = interpola1(ti, ta, v01, tb, v12);
  #local v123 = interpola1(ti, ta, v12, tb, v23);
  #local v0123 = interpola1(ti, ta, v012, tb, v123);
  v0123
#end

#macro teste_interpola_1(p0, p1, p2, p3, n, raio)
  union {
    #for(k, 0, n-1)
      #local centro = interpola3(k, 0, n, p0, p1, p2, p3);
      object { sphere{ centro, raio texture { tx_tubo } } }
    #end
  }
#end


object {vertice_1}
object {vertice_1 translate <15, 19, 15> }


teste_interpola_1(<0, 2, 0> <-15, 0, 20>, <-9, 0, 3>, <15, 17, 15>, 230, 0.2)

eixos(20)

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 1.00 >;
#declare raio_cena = 30.0;
#declare dir_camera = < 1, 1.00, 0.5 >;
#declare dist_camera = 200*raio_cena;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)