How to calculate the angle between two rays (or two vectors)
Show older comments
I want to find the angle between two vectors, but some times, it looks not very correct.
Is there any better methods to do this?
Tx = [-1 10];
current = [2 4]; % common point
last = [0 4];
figure;
aa = [Tx;current]
plot(aa(:,1),aa(:,2),'bo-'); hold on;
aa1 = [last;current]
plot(aa1(:,1),aa1(:,2),'mo-'); hold on;
plot(current(1),current(2),'go')
angle = (atan((Tx(2)-current(2))/(Tx(1)-current(1))) - atan((last(2)-current(2))/(last(1)-current(1)))) * 180/pi
axis([-4 10 -4 10])
Accepted Answer
More Answers (0)
Categories
Find more on Lengths and Angles in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!