function tube_plot(curve, rad1, rad2, segs, colors)

  number_curves = size(curve, 2) / 3;
  curve_length  = size(curve, 1);

  tvals = zeros(4, number_curves*(curve_length-1)*segs);
  xvals = tvals; yvals = tvals;
  cvals = zeros(1, number_curves*(curve_length-1)*segs);

  for n = 1:number_curves do

    for c = (n-1)*(curve_length-1)+1:n*(curve_length-1) do
      p1 = c-(n-1)*(curve_length-1);
      p2 = p1+1;
      d1 = (n-1)*3+1;
      d2 = (n-1)*3+2;
      d3 = (n-1)*3+3;

      for r = 0:segs-1 do

        a1 =  r   *2*%pi/segs;
        a2 = (r+1)*2*%pi/segs;

        tvals(:,(c-1)*segs+r+1) = ...
          [curve(p1,d1) + rad1(p1,d1)*cos(a1) + rad2(p1,d1)*sin(a1); ...
           curve(p1,d1) + rad1(p1,d1)*cos(a2) + rad2(p1,d1)*sin(a2); ...
           curve(p2,d1) + rad1(p2,d1)*cos(a2) + rad2(p2,d1)*sin(a2); ...
           curve(p2,d1) + rad1(p2,d1)*cos(a1) + rad2(p2,d1)*sin(a1)     ]

        xvals(:,(c-1)*segs+r+1) = ...
          [curve(p1,d2) + rad1(p1,d2)*cos(a1) + rad2(p1,d2)*sin(a1); ...
           curve(p1,d2) + rad1(p1,d2)*cos(a2) + rad2(p1,d2)*sin(a2); ...
           curve(p2,d2) + rad1(p2,d2)*cos(a2) + rad2(p2,d2)*sin(a2); ...
           curve(p2,d2) + rad1(p2,d2)*cos(a1) + rad2(p2,d2)*sin(a1)     ]

        yvals(:,(c-1)*segs+r+1) = ...
          [curve(p1,d3) + rad1(p1,d3)*cos(a1) + rad2(p1,d3)*sin(a1); ...
           curve(p1,d3) + rad1(p1,d3)*cos(a2) + rad2(p1,d3)*sin(a2); ...
           curve(p2,d3) + rad1(p2,d3)*cos(a2) + rad2(p2,d3)*sin(a2); ...
           curve(p2,d3) + rad1(p2,d3)*cos(a1) + rad2(p2,d3)*sin(a1)     ]

        cvals((c-1)*segs+r+1) = colors(r+1);

      end //for r
    end //for l
  end //for n

  plot3d(tvals,xvals,list(yvals,cvals),35.,45.,"t@x@y");

//end tube_plot
