필터 지우기
필터 지우기

Why doesn't atan2 (u,v) give me the right angle of two simple vectors?

조회 수: 6 (최근 30일)
farzad
farzad 2019년 6월 4일
편집: Jan 2019년 6월 28일
Hi All
I was using the atan2(u,v) to calculate the angles between vectors, untill I checked it for
u=[0,0,0]
v= [1,1,1]
doing :
teta=atan2(norm(cross(u,v)),dot(u,v));
I get teta = 0
I am expecting teta = 54 °
where am I going wrong ?
  댓글 수: 1
KSSV
KSSV 2019년 6월 4일
Why do you expect it to be 54? IT is showing correct.
teta=atan2d(norm(cross(u,v)),dot(u,v));

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2019년 6월 4일
편집: Jan 2019년 6월 4일
Of course this code replies 0. If one of the vectors is the Null vector, there cannot be an angle different from 0.
So the only problem is that you expect 54°. atan2 will not reply degrees at all, but radians.
u = [1, 0, 0]
v = [cos(0.123), -sin(0.123), 0]
atan2(norm(cross(u,v)),dot(u,v))
>> 0.1230 % As expected

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by