Fill the interior of a cylinder surface - SURF - generated by parametric equations

I've generated a cylinder using the parametric equations:
u = linspace(0,2*pi,50);
v = linspace(0,2*pi,50);
[u,v] = meshgrid(u,v);
x = cos(u);
y = sin(u);
z = v;
where u and v are 0-pi.
I've got a plot surf(x,y,z) of this cylinder and I want to fill all the interior points. Does anyone know how I can do this?
How can I do this?

4 件のコメント

William
William 2015 年 3 月 5 日
..
Brendan Hamm
Brendan Hamm 2015 年 3 月 5 日
By fill the interior points, do you mean you want each (x,y,z) pair inside to contain a marker of some sort or do you want there to be surfaces at each of the heights in z?
Andrew Newell
Andrew Newell 2015 年 3 月 5 日
Or do you mean that you want to cap the ends so it looks solid?
William
William 2015 年 3 月 6 日
I want it to be "physically" solid, so the interior points also have markers. Ideally so it is represented in binary i.e. 1 - where it is, 0 - where it isn't

サインインしてコメントする。

 採用された回答

Brendan Hamm
Brendan Hamm 2015 年 3 月 5 日
編集済み: Brendan Hamm 2015 年 3 月 5 日
If you are trying to just put anything in that location you can do the following to place circles there. First create a meshgrid of the x-y space.
surf(x,y,z)
hold on
u2 = linspace(-1,1);
v2 = u2;
[x2, y2] = meshgrid(u2,v2);
% Find distances
dist = sqrt(x2.^2 + y2.^2);
dist(dist>1) = 1;
dist(dist<1) = 0;
dist = logical(dist); % Logical matrix of exterior points
% Set exterior points to NaN
x2(dist) = NaN;
y2(dist) = NaN;
z2 = 2*pi*ones(size(x2)); % Just the highest point.
scatter3(x2(:),y2(:),z2(:)); % Scatter expects vectors, so stack everything
If you wish, you can fill the markers, change the colors, etc. If you need all the points filled you just need to do this for each value of z(:,1);

3 件のコメント

William
William 2015 年 3 月 6 日
this would work for a straight cylinder, I'm just trying to think how it could relate to more complex tubes e.g. a spiral
I need to include the specific parametric equations in the filling, rather than just define a new shape of the same dimensions.
(eventually the radius will vary also, so stacking circles may get a bit complicated, but possible i suppose)
Brendan Hamm
Brendan Hamm 2015 年 3 月 8 日
The process would be similar as you can still solve for the boundary of your shape at each value of z in your grid.
Jetsadaporn Simsiriwong
Jetsadaporn Simsiriwong 2017 年 8 月 15 日
Can i get your spiral code pls?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by