The code below is great which generates a cone of infinite points. Could anyone help me how to fix the number of points. For example, if i want only 10, 000 points or 20,000 point on the cone. How can i fix on the cone using code below. Thanks for support and help. Regards.
r1=input('enter radius'); r=r1:-0.5:0; h=input('enter ht');% --------------------
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;figure(2)scatter3(Xc, Yc, Hc, pointsize, 'filled')
Best Answer