How can i measure Angle in 3-D?

조회 수: 5 (최근 30일)
Mahmoud Sami
Mahmoud Sami 2018년 9월 8일
댓글: Mahmoud Sami 2018년 9월 22일
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
KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 9월 8일
Angle between?
Mahmoud Sami
Mahmoud Sami 2018년 9월 8일
편집: Mahmoud Sami 2018년 9월 8일
The 1st line connected between the first point and the second one, the second line connected between the second point and the third one, to the end of S. The angle the 1st line and 2nd line. Then 2nd line and 3 rd line.

댓글을 달려면 로그인하십시오.

채택된 답변

Jim Riggs
Jim Riggs 2018년 9월 9일
편집: Jim Riggs 2018년 9월 9일
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
Jim Riggs
Jim Riggs 2018년 9월 11일
편집: Jim Riggs 2018년 9월 11일
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.
Mahmoud Sami
Mahmoud Sami 2018년 9월 22일
Thanks for your answer. Sorry for late feedback.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Aquatris
Aquatris 2018년 9월 9일
Check out this link which has the answer.
  댓글 수: 1
Mahmoud Sami
Mahmoud Sami 2018년 9월 11일
Thanks for your answer. I ask for Matlab coding for that.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by