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

34 views (last 30 days)
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!

Accepted Answer

Mahesh Taparia
Mahesh Taparia on 16 Dec 2020
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))

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!