|
-
Mar 25th, 2005, 03:58 PM
#1
Wrapping radians...
how do you 'wrap' a large radians value so it falls within one revolution?
If the input was larger than 2pi (a full revolution) then the answer would go back to 0. My inputs are single datatype and must maintain accuracy. I can't use Mod for this because that only works on integers.
It must work with negative numbers too.
My brain hurts.
I don't live here any more.
-
Mar 25th, 2005, 05:33 PM
#2
Re: Wrapping radians...
Maybe:
If x is the angle, the same angle limited to one revolution would be
x - 2*Pi*INT[x / (2*Pi)] for positive x.
If x is negative, then first let y = 2*Pi - x and
apply the above formula to y. Then change the sign of the result.
I haven't checked it thoroughly though.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Mar 26th, 2005, 12:10 PM
#3
Re: Wrapping radians...
Right. Well I have this...
VB Code:
Public Function RectifyRadians(ByVal rads As Single) As Single
'if makes sure the value is inside the range 0-2Pi (no negative angles or angles greater than 2 revolution)
'(2pi and zero are valid results)
Dim temp As Single = rads / FULL_ROTATION
Return rads - (Int(temp) * FULL_ROTATION)
End Function
...which works fine, BUT it uses the old legacy Int() function from VB6. I can't make it work otherwise. This is odd. I'll try to do it in VB.net instead...
I don't live here any more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|