Computing Angles from Coordinate Space
1 回表示 (過去 30 日間)
古いコメントを表示
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
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
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 件のコメント
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 Center および File Exchange で Axes Transformations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!