Computing Angles from Coordinate Space
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Matt J
il 10 Dic 2014
You haven't said what problem you're encountering, i.e., what you don't like about the result of your current code.
Risposte (1)
Roger Stafford
il 10 Dic 2014
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 Commenti
Roger Stafford
il 12 Dic 2014
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.
Vedere anche
Categorie
Scopri di più su Axes Transformations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!