Filter löschen
Filter löschen

how to measure angle between the lines?

13 Ansichten (letzte 30 Tage)
BV
BV am 6 Jun. 2013
Bearbeitet: MFB am 15 Apr. 2019
I have plotted the lines with the following code.
x = [3 0];
y = [0 9];
line(x,y);
a = [1 2];
b = [0 3];
line(a,b);
axis([0 4 0 10]);
Now, how can I measure the angle between these lines?
  2 Kommentare
Jan
Jan am 6 Jun. 2013
Bearbeitet: Jan am 6 Jun. 2013
The mathematical angle, the angle of the created lines in screen coordinates or the physical angle on the screen (while the last two are almost identical on modern flat screens, while they can differ substantially on arched CRT monitors)?
Do you want to "measure" the angle or to calculate it?
BV
BV am 6 Jun. 2013
i wanted a way to calculate the angle.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Iain
Iain am 6 Jun. 2013
diff = (atan((y(2)-y(1))/(x(2)-x(1))) - atan((b(2)-b(1))/(a(2)-a(1)))) * 180/pi;
  5 Kommentare
BV
BV am 6 Jun. 2013
thank u very much.
MFB
MFB am 15 Apr. 2019
Bearbeitet: MFB am 15 Apr. 2019
difference = (atan((y(2)-x(2))/(y(1)-x(1))) - atan((b(2)-a(2))/(b(1)-a(1)))) * 180/pi;
actually this will be the correct formula arrangement if you consider x as vector points and y as vector points making a line together and a and b making a line together. Algebraically, Jan gave correct formula to calculate angle difference. Thanks.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Paul Kelly
Paul Kelly am 6 Jun. 2013
You can fit a straight line using polyval:
p = polyval(x, y, 1)
p(1) is the gradient and you can calculate the angle:
a = atan(p(1))
If you do this for each line you have two angles and can calculate the difference
Whether you mean measure or calculate (as per Jan's question) you will have to decide the coordinate system
  3 Kommentare
Iain
Iain am 6 Jun. 2013
"plot3" is a function that lets you plot lines in 3D.
If you are trying to find the angle between two lines, in a 3D space, then my solution is NOT the one you want. Mine only works for coplanar lines and an axis set that matches that plane.
benedikta siboro
benedikta siboro am 8 Mai 2018
I want to measure angle of human body using GUI.how i can measure?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Polar Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by