From 7821964f6e4512fdd5164579981f97d6bbcf6283 Mon Sep 17 00:00:00 2001 From: lmaresz <lmaresz@sch.bme.hu> Date: Fri, 12 Jun 2020 10:47:03 +0200 Subject: [PATCH] BalazsAperture inherited from Aperture, minor fixes --- RTX class/Antenna.m | 6 +++--- RTX class/BalazsAperture.m | 29 +++++------------------------ RTX class/FarField.m | 7 ++++--- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/RTX class/Antenna.m b/RTX class/Antenna.m index 1afd634..29eb040 100644 --- a/RTX class/Antenna.m +++ b/RTX class/Antenna.m @@ -1,9 +1,9 @@ classdef Antenna properties + position Vect; amplitude = ones(1, 1000); phase = zeros(1, 1000); - integral; - position Vect; + integral = zeros(1, 1000); end methods @@ -15,7 +15,7 @@ classdef Antenna end dPhi = 2 * pi / length(obj.amplitude); for j=1:length(obj.amplitude) - obj.integral(j) = sum(amplitude(1:j)*dPhi); + obj.integral(j) = sum(obj.amplitude(1:j)*dPhi); end end diff --git a/RTX class/BalazsAperture.m b/RTX class/BalazsAperture.m index 28dc824..f4f737b 100644 --- a/RTX class/BalazsAperture.m +++ b/RTX class/BalazsAperture.m @@ -1,11 +1,7 @@ -classdef BalazsAperture < Barrier +classdef BalazsAperture < Aperture properties - center Vect = Vect; % center position - size double = 0; % full size of reflector (end to end) - color = [0.5 0.5 0.5]; - width = 2; nslice = 1; %change from original - collisions = 0; + collisions = []; end methods function obj = BalazsAperture(center, size, nslice) @@ -16,22 +12,11 @@ classdef BalazsAperture < Barrier obj.collisions = zeros(1, nslice); end end - function col = collide(obj, ray) % override this function with custom collision - col = Collision; - col.stop = true; - - k = (obj.center.x - ray.start.x)/ray.dir.x; - col.pos = ray.start + k*ray.dir; - col.reflDir = Vect(-ray.dir.x, ray.dir.y); - if abs(col.pos.y - obj.center.y) < obj.size/2 && k*ray.dir.mag > 1e-6 - col.collided = true; - else - col.collided = false; - end - end + function histogram = getCollisionHistogram(obj) %change from original histogram = obj.collisions; end + 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; @@ -39,10 +24,6 @@ classdef BalazsAperture < Barrier obj.collisions(i) = obj.collisions(i) + exp(1i*phase); end end - function plot_self(obj) - plot([obj.center.x obj.center.x],... - [obj.center.y - obj.size/2, obj.center.y + obj.size/2],... - 'LineWidth', obj.width, 'Color', obj.color); - end + end end diff --git a/RTX class/FarField.m b/RTX class/FarField.m index 63ac71d..78f176b 100644 --- a/RTX class/FarField.m +++ b/RTX class/FarField.m @@ -5,19 +5,20 @@ classdef FarField end methods (Static) - function field = CalculateFarField(ntheta, nfi, apertureSize, wavelength, histogram) + function field = CalculateFarField(ntheta, nfi, apertureSize, wavelength, histogram) progressBar2 = waitbar(0,'Calculating far field...','Name','Calculating far field...',... 'CreateCancelBtn','setappdata(gcbf,''canceling'',1)'); setappdata(progressBar2,'canceling',0); stepSize = ntheta/100; - + field = zeros(1, ntheta); theta = linspace(-pi/6, pi/6, ntheta); fi = linspace(0, 2*pi, nfi); nr = floor(length(histogram)/2); r = linspace(0, apertureSize/2, nr); c1 = (apertureSize/(2*nr))*2*pi/nfi; - c2 = 1i*2*pi/wavelength; + c2 = 1i*2*pi/wavelength; + for i = 1:ntheta if getappdata(progressBar2,'canceling') break; -- GitLab