-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdraw_3d_scene.m
81 lines (66 loc) · 1.81 KB
/
draw_3d_scene.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function [] = draw_3d_scene(head, ptv, oar)
%Written by: Stefano Roque
%Student ID: 15sdr3
%Student #: 20009317
%This function draws a 3d scene containing the head, PTV, OAR, isocenter,
%dose box, and coordinate axis
%Input:
%head = row vector containing the center point and x, y, z coordinates for the elipsoid
%ptv = row vector containing the center point and radius of the ptv
%oar = row vector containing the center point and radius of the oar
%Output:
%3d plot containing the scene
figure;
hold on;
title("3D Scene");
xlabel("X-axis (mm)");
ylabel("Y-axis (mm)");
zlabel("Z-axis (mm)");
axis equal;
%plot the coordinate axis
plot3([0, 15], [0, 0], [0, 0], "black");
plot3([0, 0], [0, 15], [0, 0], "black");
plot3([0, 0], [0, 0], [0, 15], "black");
%plot the head
hx = head(1,1);
hy = head(1,2);
hz = head(1,3);
ha = head(1,4);
hb = head(1,5);
hc = head(1,6);
[x, y, z] = ellipsoid(hx,hy,hz,ha,hb,hc);
h = surf(x, y, z);
set(h, 'FaceAlpha', 0.2)
shading interp
%plot the PTV
ptv_x = ptv(1,1);
ptv_y = ptv(1,2);
ptv_z = ptv(1,3);
ptv_rad = ptv(1,4);
[x,y,z] = sphere;
ptv_surf=surf(ptv_rad*x+ptv_x, ptv_rad*y+ptv_y, ptv_rad*z+ptv_z);
set(ptv_surf, 'FaceAlpha', 0.5)
shading interp
%plot the OAR
oar_x = oar(1,1);
oar_y = oar(1,2);
oar_z = oar(1,3);
oar_rad = oar(1,4);
[x,y,z] = sphere;
oar_surf=surf(oar_rad*x+oar_x, oar_rad*y+oar_y, oar_rad*z+oar_z);
set(oar_surf, 'FaceAlpha', 0.5)
shading interp
%plot the isocenter
plot3(ptv_x, ptv_y, ptv_z, "*");
%Plot the PTV dose box
ptv_dose_box = compute_dose_box([ptv_x, ptv_y, ptv_z], ptv_rad);
corner1 = ptv_dose_box(1,:);
corner2 = ptv_dose_box(2,:);
cube_plot_diag(corner1 ,corner2, 'b');
%Plot the OAR dose box
oar_dose_box = compute_dose_box([oar_x, oar_y, oar_z], oar_rad);
corner1 = oar_dose_box(1,:);
corner2 = oar_dose_box(2,:);
cube_plot_diag(corner1 ,corner2, 'r');
hold off;
end