How calculate the points inside the square and triangle?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Antworten (1)
KSSV
am 6 Jun. 2018
Read about inpolygon. This function will give you indices of the points lying inside a polygon.
2 Kommentare
Image Analyst
am 10 Jun. 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.
Siehe auch
Kategorien
Mehr zu Mathematics and Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!