-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_plotRays3D2D.m
More file actions
133 lines (92 loc) · 3.76 KB
/
Copy pathtest_plotRays3D2D.m
File metadata and controls
133 lines (92 loc) · 3.76 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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
function tests = test_plotRays3D2D
tests = functiontests(localfunctions);
end
function test_plotRays3D2D_withRaytraceSurface(~)
numberOfRays = 1;
raysIn = Ray3D([0e-3, 0e-3, -2e-3], [0,0.2,0.8], 1);
raysInCell = cell(numberOfRays,1);
for iRay = 1:1:numberOfRays
raysInCell{iRay,1} = raysIn;
end
% def first Surface
surface1 = Surface3D([0,0,30e-3], 20e-3 ,1.5);
surface2 = Surface3D([0,0,5e-3], -10e-3 ,1.5);
surface3 = Surface3D([0,0,27e-3], inf ,1);
opticalSystem = [surface1, surface2, surface3];
distances = [10e-3,5e-3,12e-3];
[raysInCell, output] =...
raytraceSurface3D(raysInCell, surface1, 1, 1.5, 10e-3);
[output, output2] =...
raytraceSurface3D(output, surface2, 1.5, 1, 5e-3);
[output2, output3] =...
raytraceSurface3D(output2, surface3, 1, 1, 12e-3);
rays = [raysInCell, output, output2, output3];
figure(1);
[~] = plotSurfaces3D2D(opticalSystem,'Color', 'black');
[~] = plotRays3D2D(rays, distances,'Color', 'red');
end
function test_plotRays3D2D_withRaytraceSystem(~)
numberOfRays = 1;
raysIn = Ray3D([0e-3, 0e-3, -2e-3], [0,-0.2,0.8], 1);
raysInCell = cell(numberOfRays,1);
for iRay = 1:1:numberOfRays
raysInCell{iRay,1} = raysIn;
end
% def first Surface
surface1 = Surface3D([0,0,30e-3], 20e-3 ,1.5);
surface2 = Surface3D([0,0,5e-3], -10e-3 ,1.5);
surface3 = Surface3D([0,0,27e-3], inf ,1);
opticalSystem = [surface1, surface2, surface3];
distances = [10e-3,5e-3,12e-3];
[raysInCell, output] =...
raytraceSurface3D(raysInCell, surface1, 1, 1.5, 10e-3);
[output, output2] =...
raytraceSurface3D(output, surface2, 1.5, 1, 5e-3);
[output2, output3] =...
raytraceSurface3D(output2, surface3, 1, 1, 12e-3);
rays = [raysInCell, output, output2, output3];
figure(2);
[~] = plotSurfaces3D2D(opticalSystem, 'black');
[~] = plotRays3D2D(rays, distances);
[~] = plotRays3D2D(rays, distances,'Color','red');
end
function test_plotRays3D2D_withRaytraceSystem2(~)
% get input rays
raysIn = getRay3DBundle(20,[0,0],[0,0],[0,0],...
[0,0],[0.5,-0.5],[0,0]);
% def first Surface
surface1 = Surface3D([0,0,30e-3], 20e-3 ,1.5);
surface2 = Surface3D([0,0,5e-3], -10e-3 ,1.5);
surface3 = Surface3D([0,0,30e-3+20e-3], 20e-3 ,1.5);
surface4 = Surface3D([0,0,5e-3+20e-3], -10e-3 ,1.5);
surface5 = Surface3D([0,0,27e-3+20e-3], inf ,1);
opticalSystem = [surface1, surface2, surface3, surface4, surface5];
distances = [10e-3,5e-3,15e-3,5e-3,12e-3];
ns = [1, 1.5, 1, 1.5, 1, 1];
rays = raytraceSystem3D(raysIn, opticalSystem, ns, distances);
figure(3);
[~] = plotSurfaces3D2D(opticalSystem, 'black');
[~] = plotRays3D2D(rays, distances, 'Color', 'red');
end
function test_plotRays3D2D_notValidInput(testCase)
numberOfRays = 1;
raysIn = Ray3D([0e-3, 0e-3, -2e-3], [0,-0.2,0.8], 1);
raysInCell = cell(numberOfRays,1);
for iRay = 1:1:numberOfRays
raysInCell{iRay,1} = raysIn;
end
% def first Surface
surface1 = Surface3D([0,0,30e-3], 20e-3 ,1.5);
surface2 = Surface3D([0,0,5e-3], -10e-3 ,1.5);
surface3 = Surface3D([0,0,27e-3], inf ,1);
distances = [10e-3,5e-3,12e-3];
[raysInCell, output] =...
raytraceSurface3D(raysInCell, surface1, 1, 1.5, 10e-3);
[output, output2] =...
raytraceSurface3D(output, surface2, 1.5, 1, 5e-3);
[output2, output3] =...
raytraceSurface3D(output2, surface3, 1, 1, 12e-3);
rays = [raysInCell, output, output2, output3];
verifyError(testCase,@()plotRays3D2D(rays, distances','Color','red'),...
'plotRays3D2D:InputDataSize')
end