% function [point, edge, face] = create_body( x, l, r1, r2, n )
% In:
%   x .. centre of lower plane
%   l .. height
%   r1, r2 .. lower, upper radius
%   n .. number of points
% Out:
%   point, edge, face .. selfexplanatory
function [point, edge, face] = create_body( x, l, r1, r2, n )
  
  fi = linspace( 0, 2 * pi, n+1 );
  fi = fi(1:n);
  
  tmp = [cos( fi ); sin( fi ); zeros( size( fi ) )];
  p = repmat( x(:), 1, n ) + r1 * tmp;
  for i = 1:n
    r(:,i) = x(:) + [0; 0; l] + r2 * tmp(:,i);
  end
  point = [p r];

  % Edges.
  edge = zeros( 3 * n, 2 );
  edge(1:n,:) = [1:n; n + [1:n]]';
  for i = 1:n-1
    edge(n+i,:) = [i, i+1];
    edge(2*n+i,:) = [n+i, n+i+1];
  end
  edge(2*n,:) = [n, 1];
  edge(3*n,:) = [2*n, n+1];
  
  % Faces - lower plane.
  face(1).p(1:n) = 1:n;
  face(1).n = 1;

  % Faces - upper plane.
  face(2).p(1:n) = n+1:2*n;
  face(2).n = 2;
  
  % Faces - walls.
  for i = 1:n
    ii = (i < n) * (i + 1) + (i == n);
    face(i+2).p = [i, ii, ii+n, i + n];
    face(i+2).n = i+2;
  end
