How can i measure Angle in 3-D?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mahmoud Sami
am 8 Sep. 2018
Kommentiert: Mahmoud Sami
am 22 Sep. 2018
I have points
S =[0.5360 0.8850 2.3962;
0.5360 0.8850 2.4291;
0.5436 0.1708 1.8550;
0.7532 0.8089 0.9649;
0.9630 0.4010 1.1216]
plot3(S(:, 1), S(:, 2), S(:, 3), 'b.', 'MarkerSize', 30, 'LineWidth', 2);
grid on;
These points are connected to make connected lines. How can I measure the angle between the lines?
2 Kommentare
Akzeptierte Antwort
Jim Riggs
am 9 Sep. 2018
Bearbeitet: Jim Riggs
am 9 Sep. 2018
The link in the answer by Aquatris is not working for me.
The angle between any two lines is given by the dot product.
Define each line segment as a vector from one point to the next in the point sequence, i.e. segment D1 = P2 - P1 = {P2x-P1x, P2y-P1y, P2z-P1z}. Likewise, define segment D2 as P3 - P2 = {P3x-P2x, P3y-P2y, P3z-P2z}. Now normalize these two vectors to make then unit vectors U1 = D1/|D1| and U2 = D2/|D2|.
Take the dot product of U1 and U2; this is the cosine of the angle between line segment 1 and 2.
4 Kommentare
Jim Riggs
am 11 Sep. 2018
Bearbeitet: Jim Riggs
am 11 Sep. 2018
If you want some help visualizing the angles in the 3D plot, add the rotation axis to the plot as follows;
Add the calculation of the normal vector for each angle vertex right after the angle calculation inside the for loop:
ang(j) = acosd(dot(U1,U2));
norm(j) = 0.1*cross(U1,U2);
I use a 0.1 scale factor so that this line is not too long in the plot. Now make the 3D plot, and add the normal vectors to the plot as follows:
% The first part is the same as your plot, except I have drawn the lines connecting the points
figure();
plot3(S(:,1), S(:,2),S(:,3),'-ob','MarkerSize',6,'LineWidth',2);
grid on;
axis equal;
% now add the normal vectors
hold on;
for j=1:n-2
Vt = norm(j,:) + S(j+1,:)
plot3([S(j+1,1) Vt(1)], [S(j+1,2) Vt(2)], [S(j+1,3) Vt(3)] 'r','LineWidth',3)
end
These red lines are the rotation axes for each angle. Note that using "axis equal" makes all three axes of equal scale so that line lengths are drawn proportionally, and this makes the angles look right.
Now you can rotate the 3D plot and the red lines will help you line up the view to visualize the angles.
The five points in your S matrix define 4 line segments and 3 angles. I calculate the three angles to be 51.2, 93.2, and 48.8 degrees.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots 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!