aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--beam_trace.m10
-rw-r--r--example_beam_trace.m5
2 files changed, 8 insertions, 7 deletions
diff --git a/beam_trace.m b/beam_trace.m
index 0896975..90359d4 100644
--- a/beam_trace.m
+++ b/beam_trace.m
@@ -1,10 +1,11 @@
-function img = beam_trace(beams, faces, borders, border_limits, img)
+function [processed_beams] = beam_trace(beams, faces, borders, border_limits)
%% trace beam and all it reflections and refractions on faces
% for beams and faces structure description see face_beam_interaction.m
% border similar to faces cell array which enclose the beam
% i.e. it does not leave the polygon consisting of border faces
intensity_threshold = 1e-3; % intensity of the weakest beam which we still trace
+ processed_beams = {};
Nbeams=size(beams)(2);
if ( Nbeams == 0 )
@@ -17,6 +18,7 @@ function img = beam_trace(beams, faces, borders, border_limits, img)
beam=beams{i};
[is_face_hit, hit_position, hit_distance, new_beams] = face_beam_interaction(beam, faces);
if (is_face_hit)
+ beams{i}.hit_position=hit_position;
%% remove beams which are to weak to trace
N_new_beams=size(new_beams)(2);
intense_enough_beams={};
@@ -27,7 +29,8 @@ function img = beam_trace(beams, faces, borders, border_limits, img)
intense_enough_beams{intense_beams_counter}=new_beams{k};
end
end
- img = beam_trace(intense_enough_beams, faces, borders, border_limits, img);
+ [new_processed_beams] = beam_trace(intense_enough_beams, faces, borders, border_limits);
+ processed_beams=cat(2,processed_beams, new_processed_beams);
else
% beam does not hit face but it should stop and borders
beam.face=NA;
@@ -35,9 +38,10 @@ function img = beam_trace(beams, faces, borders, border_limits, img)
if (!is_face_hit)
error('borders are badly defined, the beam misses them');
end
+ beams{i}.hit_position=hit_position;
end
- img=make_beam_trace(beam, hit_position, border_limits, img);
end
+ processed_beams=cat(2,beams, processed_beams);
end
diff --git a/example_beam_trace.m b/example_beam_trace.m
index dfd3fa8..30703d2 100644
--- a/example_beam_trace.m
+++ b/example_beam_trace.m
@@ -50,10 +50,7 @@ borders={border1,border2, border3, border4};
beams={beam1,beam2};
-img=zeros(500,500);
border_limits=[-2,-2, 2,2];
figure(1);
-img = beam_trace(beams, faces, borders, border_limits, img );
+[processed_beams] = beam_trace(beams, faces, borders, border_limits );
-fig_handle=2;
-plot_beams_and_faces_figure(border_limits, img, faces, fig_handle );