Asked by laurie
on 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

Opportunities for recent engineering grads.

Apply Today
## 3 Comments

## Sean de Wolski (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/35023-comparing-angles-from-two-trajectories#comment_72794

## laurie (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/35023-comparing-angles-from-two-trajectories#comment_73589

## laurie (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/35023-comparing-angles-from-two-trajectories#comment_73591

Sign in to comment.