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

32 vues (au cours des 30 derniers jours)
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!

Réponse acceptée

Mahesh Taparia
Mahesh Taparia le 16 Déc 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))

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by