-
Notifications
You must be signed in to change notification settings - Fork 0
/
Positron.m
34 lines (29 loc) · 1.06 KB
/
Positron.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
classdef Positron
% Positron
% The Class Positron defines the properties of a simulated positron.
% No input variables are needed for initiation.
properties
coord = [0, 0, 0];
dir = [0, 0, 0];
scatter = 0;
end
methods
function obj = Positron(vInitial)
obj.coord = [0, 0, 0];
dir_r = randraw('maxwell', vInitial);
dir_theta = 2 * pi * rand();
dir_phi = asin(2 * rand() - 1);
[obj.dir(1), obj.dir(2), obj.dir(3)] =...\
sph2cart(dir_theta, dir_phi, dir_r);
obj.scatter = 0;
end
function [dir_theta, dir_phi, dir_r] = getDirSph(obj)
[dir_theta, dir_phi, dir_r] =...\
cart2sph(obj.dir(1), obj.dir(2), obj.dir(3));
end
function [coord_theta, coord_phi, coord_r] = getCoordSph(obj)
[coord_theta, coord_phi, coord_r] =...\
cart2sph(obj.coord(1), obj.coord(2), obj.coord(3));
end
end
end