Re: degrees radians conversion
- From: "Johannes Huth" <johannes-huth@xxxxxx>
- Date: Wed, 11 Feb 2009 07:29:03 +0000 (UTC)
"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
.
- Follow-Ups:
- Re: degrees radians conversion
- From: us
- Re: degrees radians conversion
- References:
- degrees radians conversion
- From: Andrew
- degrees radians conversion
- Prev by Date: Delete a row from an array
- Next by Date: Re: Problem with sin/cos of complex signal
- Previous by thread: degrees radians conversion
- Next by thread: Re: degrees radians conversion
- Index(es):
Relevant Pages
|
Loading