Computing Angles from Coordinate Space

조회 수: 1 (최근 30일)
Dan
Dan 2014년 12월 10일
댓글: Roger Stafford 2014년 12월 12일
Hello all,
I once again turn for you for help in solving what may very well be a simple solution.
The problem:
Given two feature vectors ( V1(x,y,z) and V2(x,y,z) ) that are expressed in meters extract a 2DOF (x,z) angle to represent the angle between V1 and v2.
What I've done so far:
I may have totally misunderstood the problem I am having and massively over complicated matters and gone down a totally incorrect path.
v = cross(X1, X2); %axis of rotation
angle = dot(X1,X2)/3; %cosine angle of rotation
angle = acos(cos(angle));
xx = v(1) * v(1);
yy = v(2) * v(2);
zz = v(3) * v(3);
heading = atan2(v(2) * sin(angle)- v(1) * v(3) * (1 - cos(angle)) , 1 - (yy + zz ) * (1 - cos(angle)));
attitude = asin(v(1) * v(2) * (1 - cos(angle)) + v(3) * sin(angle));
bank = atan2(v(1) * sin(angle)-v(2) * v(3) * (1 - cos(angle)) , 1 - (xx + zz) * (1 - cos(angle)));
Thanks
Dan
  댓글 수: 1
Matt J
Matt J 2014년 12월 10일
You haven't said what problem you're encountering, i.e., what you don't like about the result of your current code.

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

답변 (1개)

Roger Stafford
Roger Stafford 2014년 12월 10일
The two lines
angle = dot(X1,X2)/3; %cosine angle of rotation
angle = acos(cos(angle));
don't make sense to me. On the first of these lines you seem to be assuming that the product of the norms of X1 and X2 is 3. Is that true? Then on the second line you take the cosine of a quantity that is presumably already the cosine of an angle and then take its arccosine again. Such operations do not give you an angle and yet you later treat it as if it were an angle.
  댓글 수: 2
Dan
Dan 2014년 12월 12일
Hi Roger,
Thanks for your reply. As the post suggests. This is an attempt by me to solve the problem. However, I highly suspect my approach is not correct. I was hoping to have some guidance from the community. Having made an attempt myself, and knowing it isn't correct I wanted to reach out for help!
Dan
Roger Stafford
Roger Stafford 2014년 12월 12일
You can find the angle in radians between two 3D vectors, V1 and V2, this way:
ang = atan2(norm(cross(V1,V2)),dot(V1,V2));
The answer will lie between 0 and +pi. This is more accurate than using 'acos'.
As for the rest of your proposed computations, I could not tell from your code what 'heading', 'altitude', and 'bank' refer to. Perhaps you should explain the situation in ordinary English instead of matlab code to see if the latter is valid.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by