function  ob = ftore(Ra,ra,x0,y0,z0,tp)
% function  ob = ftore(Ra,ra,x0,y0,z0,tp)
% Ra = rayon de courbure
% ra = rayon du tube
% x0 = position en x
% y0 = position en y
% z0 = position en z
% tp = type (1=surf;2=surfl)

[th,ua]=meshgrid(0:pi/50:2*pi,0:pi/50:2*pi);
x=(Ra+ra*cos(ua)).*cos(th);
y=(Ra+ra*cos(ua)).*sin(th);
z=ra*sin(ua);

switch tp
case 1
   ob=surf(x+x0,y+y0,z+z0);
case 2
   ob=surfl(x+x0,y+y0,z+z0);
end

%© by Cédric Blaser / 27.11.2001