javascript - radians sometimes flipped/reversed -
i have function should finding middle of 2 radians
function mrad(rb,ra){return (rb+ra)/2;}
but when plot x , y math.sin , math.cos 2 specified length new coordinates coming out @ polar opposites of intend.
for example; if expect new points down , right coming out , left. the coordinates correct apart this!
here how plot new x , y
xnew=xold-(100)*math.cos(radian); xnew=yold+(100)*math.sin(radian);
i guessing might matter if radian b (rb) bigger ra. think happening going full circle in case, whereas should instead doing like
function mrad(rb,ra){return (rb-ra)/2;}
my questions are
is assumption correct?
what condition, how tell when rb-ra vs rb+ra, or put better, how tell if 1 radian pointing above or bellow other?
it should this
function mrad(rb,ra){return ((/*condition*/)?(rb-ra):(rb-ra))/2;}
edit
to find range have tried express different values find range in radians cannot find more diagonal line
also defined length not 100 written in example
it's maths question. need make sure angles in same range (either -pi ... pi
or 0 ... 2.0 * pi
), then, taking mean of them not find angle looking - might expect (in degrees, simplicity) answer want 10º & 20º 15º, expect 175º , -175º? suspect want 180º (as minor arc between them), 0º.
so, need test difference, see less 180º (pi radians) apart, , modify answer accordingly if not.
Comments
Post a Comment