diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-07-07 01:21:13 -0400 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-07-07 01:21:13 -0400 |
commit | 2e6895ec0b70ba97e06c00f0447f86ad162181fd (patch) | |
tree | 9538ba48e8024c5d874096a81ea0c58f627a5edb /beam_trace.m | |
parent | 84d4eb8037900b684030a28851a23fcfcfc1ee21 (diff) | |
download | wgmr-2e6895ec0b70ba97e06c00f0447f86ad162181fd.tar.gz wgmr-2e6895ec0b70ba97e06c00f0447f86ad162181fd.zip |
arbitrary beam tracing
Diffstat (limited to 'beam_trace.m')
-rw-r--r-- | beam_trace.m | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/beam_trace.m b/beam_trace.m new file mode 100644 index 0000000..401391a --- /dev/null +++ b/beam_trace.m @@ -0,0 +1,31 @@ +function ret = beam_trace(beams, faces, borders) + %% 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 + + Nbeams=size(beams)(2); + if ( Nbeams == 0 ) + % no more beam to trace + return; + end + + % trace each beam in beams cell array + for i=1:Nbeams + beam=beams{i}; + [is_face_hit, hit_position, hit_distance, new_beams] = face_beam_interaction(beam, faces); + if (is_face_hit) + beam_trace(new_beams, faces, borders ); + continue; + end + + % beam does not hit face but it should stop and borders + beam.face=NA; + [is_face_hit, hit_position, hit_distance, new_beams] = face_beam_interaction(beam, borders); + if (!is_face_hit) + error('borders are badly defined, the beam misses them'); + end + end +end + + |