-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSpherical.m
More file actions
36 lines (24 loc) · 1.12 KB
/
Spherical.m
File metadata and controls
36 lines (24 loc) · 1.12 KB
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
35
36
classdef Spherical < ChiDist
properties
R = 5; % default radius of sphere (in [mm])
end
methods
function obj = Spherical( matrix, image_res, R, sus )
% Method Spherical (constructor)
% - Call superclass constructor.
obj = obj@ChiDist( matrix, image_res, sus, 'Spherical' ) ;
% - Define class properties.
obj.R = R;
obj.spherical();
end
function obj = spherical(obj)
% define image grid
[x,y,z] = ndgrid(linspace(-(obj.matrix(1)-1)/2,(obj.matrix(1)-1)/2,obj.matrix(1)),linspace(-(obj.matrix(2)-1)/2,(obj.matrix(2)-1)/2,obj.matrix(2)),linspace(-(obj.matrix(3)-1)/2,(obj.matrix(3)-1)/2,obj.matrix(3)));
% radial position (in [mm])
r = sqrt((x.*obj.image_res(1)).^2 + (y.*obj.image_res(2)).^2 + (z.*obj.image_res(3)).^2);
obj.volume = zeros(obj.matrix(1), obj.matrix(2), obj.matrix(3));
obj.volume(r <= obj.R ) = obj.sus(1);
obj.volume(r > obj.R ) = obj.sus(2);
end
end
end