diff options
Diffstat (limited to 'beam2face_distance.m')
-rw-r--r-- | beam2face_distance.m | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/beam2face_distance.m b/beam2face_distance.m index ba3d16b..4df0f49 100644 --- a/beam2face_distance.m +++ b/beam2face_distance.m @@ -2,10 +2,23 @@ function [hit_distance, hit_position, is_face_hit] = beam2face_distance(beam,fac %% return distance to face if beam hits it or infinity otherwise % for beams and faces structure description see face_beam_interaction.m + % defaul returning values fot the case when beam misses the face + is_face_hit = false; + hit_position = [NA, NA]; + hit_distance = Inf; + k = beam.k; % face direction or kf kf=face.vertex2 - face.vertex1; % not a unit vector + %% simple check for intersection of two vectors + % if beam are parallel no intersection is possible + % we do this via simulated cross product calculation + if ( ( k(1)*kf(2)-k(2)*kf(1) ) == 0 ) + % beams never intercept + return; + end + %% let's find the intersection of lines passing through face and light beam % we introduce parameters tb and tf % which define distance (in arb. units) along k vectors @@ -23,9 +36,6 @@ function [hit_distance, hit_position, is_face_hit] = beam2face_distance(beam,fac is_face_hit = true; else % beam misses the face - is_face_hit = false; - hit_position = [NA, NA]; - hit_distance = Inf; return; end |