I am trying to solve a dynamic problem for a 3 DOF industrial manipulator and I keep getting funny end-effector plots for the first joint (see the figure). I have tried using the alternate solution where theta=pi + theta, but this doesn't work. I resolved to manually adding 2*pi where applicable but this solution is not feasible especially when running a complex algorithm in MATLAB where I hope to use evolutionary swam-based algorithm to select the best trajectory and minimize the condition number of my observation matrix. this anomaly causes the a sharp increase in velocity and acceleration values. I would appreciate any suggestions on how can I solve this problem