Angles between points and a point different from the origin of axis?
6 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!