How calculate the points inside the square and triangle?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I did calculate the points (scatteres) located inside the circle as presented in the code. I'm wondering how I can do it for square and triangle?
I cannot find proper tag for this question.
Phantom.x_size = 50/1000; % Width of phantom [mm]
Phantom.y_size = 10/1000; % Transverse width of phantom [mm]
Phantom.z_size = 60/1000; % Height of phantom [mm]
Phantom.z_start = 30/1000; % Start of phantom surface [mm];
N = Calculate_number_of_scatterers(Phantom);
N = 1000*ceil(N/1000);
% Create the general scatterers
x = (rand (N,1)-0.5)*Phantom.x_size;
y = (rand (N,1)-0.5)*Phantom.y_size;
z = rand (N,1)*Phantom.z_size + Phantom.z_start;
% Generate the amplitudes with a Gaussian distribution
amplitudes = randn(N,1);
%Make the cyst
r = 15/2/1000; %radius of cyst[mm]
xc = 10/1000; %place of the cyst
zc = 40/1000 + Phantom.z_start;
inside = ( ((x-xc).^2 + (z-zc).^2) < r^2); % scatteres inside the cyst
amplitudes = amplitudes .* (1-inside); % amplitude of the scatteres inside the cyst
Phantom.positions = [x y z];
Phantom.amplitudes = amplitudes;
figure; plot3(Phantom.positions(:,1), Phantom.positions(:,3),Phantom.amplitudes,'.')
1 commentaire
Réponses (1)
KSSV
le 6 Juin 2018
Read about inpolygon. This function will give you indices of the points lying inside a polygon.
2 commentaires
Image Analyst
le 10 Juin 2018
You forgot to include Calculate_number_of_scatterers() so we can't do much. Give us code that at least runs and demonstrates why inpolygon() does not solve your problem.
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!