Re: degrees radians conversion



"Andrew" <awbsmith@xxxxxxxxxxxxxx> wrote in message <gmtro9$oqm$1@xxxxxxxxxxxxxxxxxx>...
Hi all,

I'm having a problem where the numeric error in converting between degrees and radians is causing problems.

What I would like to do, is define a set of real numbers X where the conversion from radians to degrees can be inverted exactly, so

(x * (180/pi)) * (pi/180) = x for all x in X

then whenever I get a value in radians I can map it to its closest value in X and problem solved. But I don't know how to do that.

I was thinking I could loop the rads->degs->rads process until it finds an exactly invertible value. I have no idea if this is guaranteed to converge, or if it will converge to a value anywhere near the original.

My other thought was that there might be a property where any x with less than c significant figures will be a member of X.

Thanks for any help,
Andrew

Hi Andrew,

Would a workaround do for you?
Simply use a Nx2 lookup table LUT where N = |X|
Each row stores the x-value and the computed radian (after your formula).
Then if you get a radian number r, find the index to the value in LUT that is closest to r:

diff = LUT(:,2)-(ones(N,1).*r); % difference between all stored radians and the requested value r
idx = find(diff==min(diff)); % find the index of the closest radian

And then use the LUT entry LUT(idx,1) as your matching number

Regards,
Joh
.



Relevant Pages

  • Happy 2pi Day!
    ... Converting between fractions of a revolution and radians ...
    (sci.math)
  • Re: Happy 2pi Day!
    ... Converting between fractions of a revolution and radians ...
    (sci.math)
  • degrees radians conversion
    ... I'm having a problem where the numeric error in converting between degrees and radians is causing problems. ...
    (comp.soft-sys.matlab)
  • traverse spreadsheet
    ... Trying to put togeter a spreadsheet to calculate an open/closed traverse, ... especially about working with radians and converting them to a bearing ...
    (microsoft.public.excel.misc)

Loading