Hello all , I have a conical section which is hollow and having variable radius and height . how to get all points inside the cone so that I can make it filled cone . I used this code -
r1=input('enter radius');
r=r1:-0.5:0;
[xc,yc,zc] = cylinder(r);
h=input('enter ht');
zc=zc*h;
figure(1)
surf(xc,yc,zc,'Facecolor','w');
grid on
axis equal

 Réponse acceptée

Walter Roberson
Walter Roberson le 24 Nov 2015

0 votes

There are an infinite number of points inside a cone.
To make a 3D object "filled", normally you just use opaque faces to draw it.

6 commentaires

yogesh jain
yogesh jain le 24 Nov 2015
yes, the points are infinite but want to represent them discretely and minimum of the points which can represent cone .
Walter Roberson
Walter Roberson le 24 Nov 2015
The minimum would be 0.
Perhaps you are talking about representation as graphics. The number of pixels is going to depend upon how large you are drawing the object and what the resolution of the display is. If you were to zoom in you would need to generate more values, and as you rotate the different lines of sight would lead to more pixels being needed along some parts of the object (and fewer pixels would be needed along other parts of the object.)
yogesh jain
yogesh jain le 24 Nov 2015
Sir , how zero points may define any shape ? If we have r=10 n h=20 then min. 10 layers of points for r and 20 layers of points for h , separated by the distance of 1 .
This is the first time in the discussion that you have indicated that you want the points on the unit lattice that are inside the cone.
xvec = floor(-r1):ceil(r1);
yvec = xvec;
hvec = 0:ceil(h);
[X, Y, H] = ndgrid(xvec, yvec, 0:floor(h));
r_at_H = r1 * (1 - H/h);
is_in_cone = abs(X) <= r1 & abs(Y) <= r1 & H <= h & sqrt(X.^2+Y.^2) <= r_at_H;
Xc = X(is_in_cone);
Yc = Y(is_in_cone);
Hc = H(is_in_cone);
pointsize = 20;
scatter3(Xc, Yc, Hc, pointsize, 'filled')
yogesh jain
yogesh jain le 19 Fév 2016
and if I know starting and ending points of cone , then ? Means it is not in generic way .
M.S. Khan
M.S. Khan le 18 Août 2020
Hi Dr. Walter Roberson, can i consider your code as a point cloud of the cone.
Regards,
M. Shafiq

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by