Finding Angle between 2 points

4 ビュー (過去 30 日間)
aaditya chandel
aaditya chandel 2020 年 4 月 20 日
コメント済み: aaditya chandel 2020 年 4 月 22 日
Hello,
I need to calculate the angle between two point from the matlab plot. I tried by applyingthe code which is provided in the discussion but the result is not correct.
The image is attached, I want to find the angle theta which is fromed by point p1,p2 and o.
P1,P2 coordinates are known to us.
I tried using the code provided in the link attached below but the answer is not correct.
I need your help regarding the same.
Thanks in Advance.
Awaiting for response.
  2 件のコメント
MaryD
MaryD 2020 年 4 月 20 日
Do you know the coordinates of O point ? Or anything about that ?
aaditya chandel
aaditya chandel 2020 年 4 月 20 日
yes the point O coordinates are known.

サインインしてコメントする。

回答 (2 件)

Gifari Zulkarnaen
Gifari Zulkarnaen 2020 年 4 月 20 日
Is this what you mean?
P1 = [10 210];
P2 = [140 210];
Z0 = [(P1(1)+P2(1))/2 225]; % Reference point, assuming it is in the middle of P1 & P2
degree = 2*atand((P2(1)-Z0(1))/(Z0(2)-P2(2)));
  3 件のコメント
aaditya chandel
aaditya chandel 2020 年 4 月 20 日
As shown in the figure P1,P2 and O point coordinates are know.
aaditya chandel
aaditya chandel 2020 年 4 月 20 日
For this case Z0 appears to be in the middle but it might not be true in other cases.
But its possible to obtain the coordiante.

サインインしてコメントする。


MaryD
MaryD 2020 年 4 月 20 日
編集済み: MaryD 2020 年 4 月 20 日
r1=sqrt((x1-xo).^2+(y1-yo).^2);
r2=sqrt((x2-xo).^2+(y2-yo).^2);
alpha=acos((x1-xo)/r1);
beta=acos((x2-xo)/r2);
theta=alpha-beta;
keep in mind that acos is specified for pi <0:pi> so if one (or both) points would be placed under O point you have to adjust this equation.
  1 件のコメント
aaditya chandel
aaditya chandel 2020 年 4 月 22 日
Thanks.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFeature Detection and Extraction についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by