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

12 次查看(过去 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!

采纳的回答

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 CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by