フィルターのクリア

Angles between points and a point different from the origin of axis?

11 ビュー (過去 30 日間)
Davide Mori
Davide Mori 2020 年 12 月 13 日
回答済み: Mahesh Taparia 2020 年 12 月 16 日
Hi everyone,
If I have the origin of axis in (0,0) and I want to calculate the angle of different lines connecting some points to the origin I would write:
orig = [0 0];
rz(:,1)=(points(:,1)- orig(:,1));
rz(:,2)=(points(:,2)- orig(:,2));
alpha_i = atan2(rz(:,2), rz(:,1));
BUT what if I want to calculate the angles just changing the origin? That is, I have for example p = [-0.5 0] and I want to calculate the angles formed by the x-axis and the points but considering a point p different from the origin. Thank you!

採用された回答

Mahesh Taparia
Mahesh Taparia 2020 年 12 月 16 日
Hi
The similar approach can be used to find the angle which you already mentioned in the question. Moreover, the point 'p' (p = [-0.5 0]) also lies on the x axis, so its angle with x axis is 0.
In general, the equation of x axis is y=0. So the angle with x axis (y1=0) and any point (x2,y2) can be written as
theta=atan2(y2/(x2-x1))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by