Filter löschen
Filter löschen

comparing angles from two trajectories

4 Ansichten (letzte 30 Tage)
laurie
laurie am 10 Apr. 2012
Hello there,
I am trying to compare the angles from two trajectories, (0,0) being at the center of the screen and the trajectories in the whole screen.
What I did was to use Arctan() to determine the polar coordinates rho(t),theta(t) from x(t),y(t) for both trajectories. To avoid problems of angles "jumping" between -pi and +pi I introduced a condition that minimalizes the gap between two successive angles, choosing between the angle returned by arctan() and the angle returned by arctan() +/- 2pi. I get less "jumps" in each angular trajectory but I am still having some important problems :
  • sometimes the trajectory crosses the origin (0,0) so that the angle cannot be calculated and I get "jumps" between the point after and the point before that.
  • this is bad because then it allows the two angular trajectories to differ more than they would differ without the "jump" (angle from the one is angle from the other +/- 2pi)
so i am looking for a way to compute a continuous angular trajectory even when the trajectory hits the origin (0,0), so that i can compare angular trajectories correctly. i could just set the origin elsewhere than in the center of the screen but the problem is that what i am really interested in is the angle with the center of the screen as a reference.
thank you, sorry i don't think this was clear at all
  3 Kommentare
laurie
laurie am 13 Apr. 2012
wow sorry i did not see your answer !!!
ok sorry atan()
atan2 might well be what i need :)
from what i understand, atan2(y,x) gives the angle formed by a point of coordinates (x,y) in an orthonormal four-quadrants, and it gives the one measure that is between pi and -pi ?
what is good is that atan2(0,0) is 0 which is what i need. :)
i am still getting some problem with the following :
i have a point that moves from (100,0.1) to (100,-0.1) so those two positions are quite close.
atan2(0.1,100)= 3.1406
atan2(-0.1,100)=-3.1406
so the distance between those two measures is huge compared to the actual distance (you have to add +/-2pi to get them closer..)
anyway thank you maybe atan2 will be the answer i need :)
laurie
laurie am 13 Apr. 2012
AWESOME :) i made some minor arrangements to account for the "continuity" problem each time the point crosses the line between -pi and pi and it is now doing exactly what i want !! thank you !!

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Coordinate Transformations and Trajectories finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by