-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseparationDistanceCalculation.m
More file actions
33 lines (27 loc) · 1.16 KB
/
separationDistanceCalculation.m
File metadata and controls
33 lines (27 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function output = separationDistanceCalculation(a, b, c)
% Initial Variables
enclosingWidth = a;
enclosingHeight = b;
viewFactor = 0;
targetViewFactor = round(c, 3);
separationDistance = 0;
% While loop failsafe
maxIterationCount = 100000;
iterationCount = 0;
% Calculating correct separation distance
% Rounds the calculated view factor to 3d.p to check if it is the correct
% distance. Also contains the loop failsafe to ensure there is no infinite
% loop occuring.
while round(viewFactor, 3) ~= targetViewFactor && iterationCount < maxIterationCount
% Neccessary calculations for view factor equiation
X = enclosingWidth/(2*separationDistance);
Y = enclosingHeight/(2*separationDistance);
% View Factor equation
viewFactor = (2/pi)*((X/sqrt(1+X*X))*atan(Y/sqrt(1+X*X))+(Y/sqrt(1+Y*Y))*atan(X/sqrt(1+Y*Y)));
% Increases separation distance and count for each iteration
separationDistance = separationDistance + 0.001;
iterationCount = iterationCount + 1;
end
output = round(separationDistance, 3);
disp('Complete')
end