How t generate cone using scattered random point cloud?

5 vues (au cours des 30 derniers jours)
M.S. Khan
M.S. Khan le 20 Oct 2020
Commenté : anuradha verma le 11 Nov 2022
Using the below code, i have geneated sphere. could anyone please guide me how to geneate cone using random scattered point cloud.
I will be very thankful. Thanks in advance to all community members for their cooperation and guidance. Regards
r = randn (10000,3);
r = round(bsxfun(@rdivide,r,sqrt(sum(r.^2,2)))*130);
x = r(:,1);
y = r(:,2);
z = r(:,3);
scatter3(x,y,z)
  3 commentaires
M.S. Khan
M.S. Khan le 20 Oct 2020
Dear KSSV, thanks for your kind reply. This code provides cone also but not random scattered point cloud. Regards
M.S. Khan
M.S. Khan le 20 Oct 2020
They are using grid that means its uniform spaced points? Could you guide me how to generate cone using scattered random point cloud.

Connectez-vous pour commenter.

Réponse acceptée

Bruno Luong
Bruno Luong le 20 Oct 2020
Modifié(e) : Bruno Luong le 20 Oct 2020
This code provides the uniform distribution on the surface of the cone
h = 3; % height
r = 1; % base radius
n = 1e4; % number of points
topcapflag = true; % include the top cap or not
rho = sqrt(rand(1,n));
z = h*rho;
if topcapflag
z(rand(1,n)<r/(h+r))=h;
end
theta = (2*pi)*rand(1,n);
rho = r*rho;
x = cos(theta).*rho;
y = sin(theta).*rho;
% graphic check
figure
plot3(x,y,z,'.')
axis equal
  1 commentaire
M.S. Khan
M.S. Khan le 21 Oct 2020
Thanks Dearest Bruno for your professional supprot. Regards!

Connectez-vous pour commenter.

Plus de réponses (1)

Ameer Hamza
Ameer Hamza le 20 Oct 2020
This is one way. The distribution is non-uniform
h = 2; % height of cone
r = 1; % maximum radius of cross section of the cone
n = 10000;
z = rand(1, n)*h;
t = rand(1, n)*2*pi;
r = interp1([0 h], [0 r], z);
[x, y] = pol2cart(t, r);
scatter3(x, y, z)
  23 commentaires
Bruno Luong
Bruno Luong le 10 Nov 2022
Modifié(e) : Bruno Luong le 10 Nov 2022
@anuradha verma, it's not difficult, if you have new question, just click on Ask, or this link:https://mathworks.com/matlabcentral/answers/questions/new
then describe the problem accurately,.
This thread is opened by the author for his problem and it's has been answered.
You question merits a new thread
anuradha verma
anuradha verma le 11 Nov 2022
Thank you sir.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by