Plot random points only in certain angles?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have an alpha emitting source placed on the left side of a tumor cell. I want the emissions to be anisotropic, all of the alpha particles entering the cell (or at least only counting them). I'm not sure how to do this in my code. In the first For-loop I am plotting the random decay paths and it looks spherical. I want it to be anisotropic, aiming at a cell to the right. My assumption is to create an If-loop or something in order to exclude certain angles but I'm not sure how to.
clear; clc ;close all; format long
% ------------------ DIRECTIONS OF ALPHA PARTICLES -------------------- %
% Here, the sources At-211 are assumed to have alpha decays pointing into many
% different directions just like plot3(u,v,w,'.') illustrates.
% The centre of the figure is the source and the dots are the different
% directions? We assumed the At-211 source to be at (R,0,0), left of the
% spherical cell. They then decay as shows by the dots, in every direction.
% Problem: We want to exclude decays NOT leading into the cell.
% Discriminate against certain angles or directions?
n = 1000; % Number of iterations, random points.
phi = zeros(n,1); % Values from for-loop put here.
theta = zeros(n,1); % Values from for-loop put here.
for i = 1:n % Iterates the random angles and length of the directions and stores above in phi, theta and s.
phi(i,1) = rand*2*pi; % Uniform, same sampling everywhere in the horizontal axis.
theta(i,1) = acos(1-2*rand); % Not uniform. More points need to be sampled in the middle than the poles.
end
u = sin(theta(:,1)).*cos(phi); % Spherical coordinate for all points. "X"
v = sin(theta).*sin(phi); % Spherical coordinate for all points. "Y"
w = cos(theta); % Spherical coordinate for all points. "Z"
l = [u v w]; % This defines the direction of alpha particles. "[x,y,z]" for each.
figure
plot3(u,v,w,'.')
% --------------------------------------------------------------------- %
% ------------------- INTERSECTION OF ALPHA WITH CELL ----------------- %
% Here, the intersections for each alpha particle is calculated in a
% spherical geometry representing the cell that is irradiated.
R = 18e-6; % Radius of sphere.
c = [0,0,0]; % Center point of sphere.
o = [R,0,0]; % Assumed all At-211 to start in the left side of sphere. Origin of the line.
d1 = zeros(1,n);
d2 = zeros(1,n);
for k = 1:n
d1(1,k) = -(dot(l(k,:),o-c)) + sqrt((dot(l(k,:),o-c)).^2 - (norm(o-c))^2 + R^2); % Distance "1" from start "o".
d2(1,k) = -(dot(l(k,:),o-c)) - sqrt((dot(l(k,:),o-c)).^2 - (norm(o-c))^2 + R^2); % Distance "2" from start "o".
% This gives us the distance to intersection for each alpha
% particle.
end
% --------------------------------------------------------------------- %
0 Kommentare
Antworten (1)
Star Strider
am 20 Dez. 2019
I have no idea what angles you want to restrict.
Assuming ‘phi’, add these assignments:
sel_phi = (phi > 0.1) & (phi < 0.5); % Include These ‘phi’ Values
phi(~sel_phi) = NaN; % Set Others To NaN
Inserting these assignments in this part of the code:
for i = 1:n % Iterates the random angles and length of the directions and stores above in phi, theta and s.
phi(i,1) = rand*2*pi; % Uniform, same sampling everywhere in the horizontal axis.
theta(i,1) = acos(1-2*rand); % Not uniform. More points need to be sampled in the middle than the poles.
end
sel_phi = (phi > 0.1) & (phi < 0.5); % Include These ‘phi’ Values
phi(~sel_phi) = NaN; % Set Others To NaN
u = sin(theta(:,1)).*cos(phi); % Spherical coordinate for all points. "X"
v = sin(theta).*sin(phi); % Spherical coordinate for all points. "Y"
w = cos(theta); % Spherical coordinate for all points. "Z"
Supply the correct angle range, and add (or substitute) similar restrictions on ‘theta’, depending on the result you want.
2 Kommentare
Star Strider
am 20 Dez. 2019
I do not understand what your code does, or what changes it needs in order to do what you want it to do.
Separating the angles most likely requires logical indexing of the sort my code does. You can use it as an example.
Is the sphere it currently plots the target, the source, or something else?
How does it fit into the context of the image in Skärmklifepp.PNG?
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots 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!