uses mode13h,crt;

const raio = 70;   {raio do circulo - X e Y}
      rtubo = 10;  {raio do tubo}
      base = 256;


var i: Word;
    sintable: array [0..360] of Integer;
    alfa, beta: word;
    vx,vy,vz, raiol:word;
    cc:byte;


procedure put (px,py,pz: word; c:byte);
var ppx,ppy:word;

begin
  ppx := px shl 8 div pz;
  ppy := py shl 8 div pz;
  putpixel(ppx,ppy,c,vga);
end;

begin

initgraph;

for i := 0 to base do SinTable[i] := Round(Sin(2*Pi*i/base) * Rtubo);

for alfa := 0 to base do
  begin
    for beta := 0 to base do
      begin
        raiol := Round(rtubo * cos(2*pi*beta/base)) + raio;
        vx := round(cos(2*pi*alfa/base) * raiol);
        vy := round(sin(2*Pi*alfa/base) * raiol);
        vz := round(sin(2*pi*beta/base) * rtubo);
        if beta = 0 then cc := 11 else cc := 8;
        put(vx+160, vy+100, 256-vz, cc);
      end;
    putpixel(160+sintable[(alfa+64) mod base], 100+sintable[alfa], 15,vga);
  end;
keypressed;

closegraph;

end.
