How to generate uniformly distributed points inside the volume of frustrum with base radius R and tip radius r and with a height of h.
    6 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    anuradha verma
 il 12 Nov 2022
  
    
    
    
    
    Commentato: anuradha verma
 il 12 Nov 2022
            I want to generate points inside the volume of a frustrum which is at a certain height h1 from  (0,0,0) and the axis of frustrum is parallel to z-axis.
0 Commenti
Risposta accettata
  Bruno Luong
      
      
 il 12 Nov 2022
        
      Modificato: Bruno Luong
      
      
 il 12 Nov 2022
  
      Here we go
r = 1;
R = 2; % must be > r
h = 3;
if R <= r
    error('Non valid parameter')
end
Zmin = r*h/(R-r); % Position where the frustrum starts
Zmax = R*h/(R-r); % Position where the frustrum ends
N = 1e4; % Number of point
zr = (Zmin/Zmax).^3;
z = (zr + (1-zr)*rand(1,N)).^(1/3);
rho = R*sqrt(rand(1,N)).*z;
theta = (2*pi)*rand(1,N);
x = rho.*cos(theta);
y = rho.*sin(theta);
z = Zmax*(1-z);
scatter3(x,y,z,'.');
axis equal
Più risposte (1)
  Image Analyst
      
      
 il 12 Nov 2022
        OK, but do you have a question?  I'm sure you used 
n = 10000; % Whatever.  It's the number of points
x = 2*R*rand(n, 1)
y = 2*R*rand(n, 1);
z = h1 * rand(n, 1);
to generate uniformly distributed points in the rectangular volume.  And then you probably threw out points outside the frustrum (truncated cone) volume by looking at each point's radius and the radius of the frustrum at that z level.  But what is your question?  Is this homework, or is there a real world use case for this?  
Vedere anche
Categorie
				Scopri di più su Image Processing Toolbox in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



