Prompt 'The Farthest Vertex of The Rectangle (X Y) :'
Prompt 'The Farthest Vertex of The Rectangle (X Y) :'
clc
prompt =
'The farthest vertex of the rectangle [x y]:'
c = input(prompt);
prompt = 'Specify first arbitrary point outside the rectangle [x y z]'
prompt =
'Specify first arbitrary point outside the rectangle [x y z]'
q = input(prompt);
a = [0 0];
b = [c(1) 0];
d = [0 c(2)];
display(a);
a = 1×2
0 0
display(b);
b = 1×2
10 0
display(c);
c = 1×2
10 6
display(d);
d = 1×2
0 6
X = 0:1:c(1);
Y = 0:1:c(2);
display(X);
X = 1×11
0 1 2 3 4 5 6 7 8 9 10
display(Y);
Y = 1×7
0 1 2 3 4 5 6
I = 0;
for i = X(1) : X(c(1))
1
for j = Y(1) : Y(c(2))
rectangle('Position',[i j 1 1]);
x1 = -(i-(i-1)/(2*sqrt(3)))+((i+(i+1))/2);
x2 = (i-(i-1)/(2*sqrt(3)))+((i+(i+1))/2);
y1 = -(j-(j-1)/(2*sqrt(3)))+((j+(j+1))/2);
y2 = (j-(j-1)/(2*sqrt(3)))+((j+(j+1))/2);
d1 = sqrt((q(1)-x1)^2 + (q(2)-y1)^2 + (q(3)^2));
d2 = sqrt((q(1)-x2)^2 + (q(2)-y2)^2 + (q(3)^2));
f1 = 1/d1;
f2 = 1/d2;
f = 0.5*(f1 + f2);
I = I + f;
end
end
display(I);
I = 0.9941