Thursday 15 March 2012

matlab - Bending a plane into a closed surface/cylinder -



matlab - Bending a plane into a closed surface/cylinder -

i'm doing mathematical experiment in matlab , result should circle in x,y-plane. sometimes, circle starts spiraling. i'm trying bend x,y-plane cylinder (as in next picture). @ moment have x , y coordinates of points.

i've tried converting them polar coordinates , utilize 'surf' commando's, nil works right now

edit: i've used plot3 command, suggested ander biguri, resulting in next figure.

the next seems more or less want

%// info xmin = -3; xmax = 3; %// piece folded cylinder rc = 5; %// cylinder radius zmaxc = 5; %// cylinder max z zminc = -5; %// cylinder min z %// spiral t = linspace(0,1,1000); r = 1+2*t; theta = 2*pi*3*t; x1 = r.*cos(theta); y1 = r.*sin(theta); %// illustration spiral. defined x1, y1 %// bending z2 = y1; phi = (x1-xmin)/(xmax-xmin)*2*pi; x2 = rc*cos(phi); y2 = rc*sin(phi); %// plot cylinder [xc yc zc] = cylinder(rc*ones(1,100),100); zc = zminc + (zmaxc-zminc)*zc; surf(xc,yc,zc) shading flat hold on %// plot bent spiral plot3(x2,y2,z2, 'k.-');

original spiral:

two views of result:

matlab plot

No comments:

Post a Comment