Quote:
Originally Posted by Aaron.Graeve
This could be fixed by using arcsin ((x1-x0)/sqrt ((x1-x0)^2+(y1-y0)^2)).
|
That actually made the problem worse. It gives the wrong answer if y1<y0.
For example: If x0=0, y0=0, x1=10, y1=-1, and alpha=90 degrees, that formula gives sigma= -5.7 degrees instead of the correct +5.7 degrees.
There's a simple alternative to arctan(dx/dy) that gives the correct angle for all values of dx and dy except when they are both zero.
Quote:
|
Regarding the smallest Delta, either a conditional check on the absolute value of Delta being larger than 180 degrees or running the delta through arcsin(sin(Delta)) could do the trick. I know the second suggestion is implemetation dependent and not the ideal method but it is a method that I think will work in most cases.
|
There's a calculation that produces the smallest angle without conditional logic or trig functions.