我有一个问题是使用 Filed II框架在幻像中创建一些几何形状。我确实创建了一个圆圈,但现在我有问题在幻像中创建一个正方形。
以下代码在Matlab中生成它。内部产生的代码行是我的问题。对于圆,我确实计算了圆内的两个点的距离,当它小于圆的半径时,它们在圆内。但我有三角形或正方形的问题。
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 = 8/2/1000; %radius of cyst[mm]
xc = 10/1000; %place of the cyst
zc = 40/1000 + Phantom.z_start;
% [in,out] = inpolygon(xc,zc,x,z);
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,'.')