From e6ab9bd2eb05226988c70800af39b69cb078771f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Frey=20Bal=C3=A1zs?= <frey.balazs96@gmail.com>
Date: Mon, 8 Jun 2020 16:12:31 +0200
Subject: [PATCH] =?UTF-8?q?f=C3=A1zis=20sz=C3=A1m=C3=ADt=C3=A1s?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 RTX class/BalazsAperture.m    | 5 +++--
 RTX class/Barrier.m           | 2 +-
 RTX class/ParabolaReflector.m | 2 +-
 RTX class/PlaneReflector.m    | 2 +-
 RTX class/Trace.m             | 2 +-
 RTX class/simclass_test.m     | 2 +-
 6 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/RTX class/BalazsAperture.m b/RTX class/BalazsAperture.m
index 32263f4..6c08f79 100644
--- a/RTX class/BalazsAperture.m	
+++ b/RTX class/BalazsAperture.m	
@@ -32,10 +32,11 @@ classdef BalazsAperture < Barrier
         function histogram = getCollisionHistogram(obj) %change from original
             histogram = obj.collisions;
         end
-        function post_collide(obj, col)
+        function post_collide(obj, col, trace)
             if (col.collided) %change from original
                 i = floor(obj.nslice*(col.pos.y-obj.center.y+obj.size/2)/obj.size) + 1;
-                obj.collisions(i) = obj.collisions(i) + 1;
+                phase = trace.init_phase + 2*pi * mod(trace.length, trace.wavelength)/trace.wavelength;
+                obj.collisions(i) = obj.collisions(i) + exp(1i*phase);
             end
         end
         function plot_self(obj)
diff --git a/RTX class/Barrier.m b/RTX class/Barrier.m
index 837aa3f..02fb51c 100644
--- a/RTX class/Barrier.m	
+++ b/RTX class/Barrier.m	
@@ -1,7 +1,7 @@
 classdef (Abstract) Barrier < matlab.mixin.Heterogeneous & handle
     methods (Abstract)
         collide(obj, ray) % override this function with custom collision
-        post_collide(obj, col)
+        post_collide(obj, col, trace)
         plot_self(obj)
     end
     
diff --git a/RTX class/ParabolaReflector.m b/RTX class/ParabolaReflector.m
index 8156d2d..6463256 100644
--- a/RTX class/ParabolaReflector.m	
+++ b/RTX class/ParabolaReflector.m	
@@ -36,7 +36,7 @@ classdef ParabolaReflector < Barrier
                 end
             end
         end
-        function post_collide(obj, col)
+        function post_collide(obj, col, trace)
         end
         function plot_self(obj)
             pri_y = -obj.diameter/2:obj.diameter/2000:obj.diameter/2;
diff --git a/RTX class/PlaneReflector.m b/RTX class/PlaneReflector.m
index 4d33c6d..0397d48 100644
--- a/RTX class/PlaneReflector.m	
+++ b/RTX class/PlaneReflector.m	
@@ -25,7 +25,7 @@ classdef PlaneReflector < Barrier
                 col.collided = false;
             end
         end
-        function post_collide(obj, col)
+        function post_collide(obj, col, trace)
         end
         function plot_self(obj)
             plot([obj.center.x obj.center.x],...
diff --git a/RTX class/Trace.m b/RTX class/Trace.m
index fb0b15c..b1e98d7 100644
--- a/RTX class/Trace.m	
+++ b/RTX class/Trace.m	
@@ -37,7 +37,7 @@ classdef Trace < handle
                     ncol = ncol + 1;
                     next_ray = Ray(col.pos, col.reflDir);
                     obj.rays(end+1) = next_ray;
-                    barriers(col_barrier).post_collide(col);
+                    barriers(col_barrier).post_collide(col, obj);
                     if col.stop
                         obj.trace_end();
                         break;
diff --git a/RTX class/simclass_test.m b/RTX class/simclass_test.m
index fc71a75..83781d8 100644
--- a/RTX class/simclass_test.m	
+++ b/RTX class/simclass_test.m	
@@ -5,7 +5,7 @@ reflectors(end+1) = BalazsAperture([3 0], 20, 1000);
 
 phi_start = -pi;
 phi_stop = pi;
-n = 1000;
+n = 10000;
 wavelength = 3e8/1e9;
 
 antenna = Antenna(Vect(1,0));
-- 
GitLab