How I can continue vector if I know two points of vector and direction vector?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone! Kindly ask if I have two points of vector A( X0, Y0, Z0) and B(Xr, Yr, Zr). And I plotted vector in a 3d cube. How I can continue the line of vector further after Xr, Yr, Zr. I need new coordinates of the point which lies on this vector and this point will be lower than B.
Thank you in advance for your help
X0 = 1.5;
Y0 = 1.5;
Z0 = 3.0;
Theta0 = 45;
Phi0 = 30;
XBar = sind(Theta0) * cosd(Phi0); %second point of ray outside of the room
YBar = sind(Theta0) * sind(Phi0);
ZBar = cosd(Theta0);
ThetaBar = Theta0;
PhiBar = Phi0;
Xr = 0;
Yr = 0.6340;
Zr = 1.2679;
plot3([X0 Xr], [Y0 Yr], [Z0 Zr])
0 Kommentare
Akzeptierte Antwort
Chunru
am 2 Mai 2023
Bearbeitet: Chunru
am 3 Mai 2023
X0 = 1.5;
Y0 = 1.5;
Z0 = 3.0;
Theta0 = 10; % azimuth
Phi0 = -45; % elev
XBar = cosd(Theta0) * cosd(Phi0); %second point of ray outside of the room
YBar = sind(Theta0) * cosd(Phi0);
ZBar = sind(Phi0);
% Reflection points along AB
% Intersection with boundary (need to check all boundaries)
% Here we use only one boudary X=3
Xr = 3;
k=(Xr-X0)/XBar;
Xr = X0 + k*XBar;
Yr = Y0 + k*YBar;
Zr = Z0 + k*ZBar;
% The incident direction
inc = [XBar YBar ZBar];
% Normal of the boundary (X=3)
s = [-1 0 0]; % pointing inside the box
% The reflection direction
% n2 = n1 -2 dot(n1, s) s
n1 = [XBar YBar ZBar]; % incident
n2 = n1 - 2*dot(n1, s)*s;
% The reflection will intersect with Z=0
Z1 = 0;
k=(Z1-Zr)/n2(3);
X1 = Xr + k*n2(1);
Y1 = Yr + k*n2(2);
Z1 = Zr + k*n2(3);
plot3([X0 Xr X1], [Y0 Yr Y1], [Z0 Zr Z1])
xlabel("x"); ylabel("y"); zlabel("z")
text([X0 Xr X1], [Y0 Yr Y1], [Z0 Zr Z1], ["X_0", "X_R", "X_1"]);
box on; grid on
set(gca, 'BoxStyle', 'full')
axis([0 3 0 3 0 3])
%view(2)
[X0 Y0 Z0; XBar YBar ZBar; Xr Yr Zr; X1 Y1 Z1]
6 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Propagation and Channel Models finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!