![]() |
Re: remainder function
Quote:
Notice the very slight difference between the glibc and Java definitions (handling of divide-by-zero). |
Re: remainder function
The "java" link you posted was to gnu libc...
|
Re: remainder function
Quote:
|
Re: remainder function
Quote:
|
Re: remainder function
Quote:
Code:
x: 179.0 rem y: 360 result: 179.0 |
Re: remainder function
Quote:
For those of you reading this thread for the first time, Math.IEEEremainder(angle,360.0) can be used to convert any angle (in degrees) to the range -180 to 180. This can be very useful when working with the gyro. Let's say you want to find the shortest angular error between your joystick direction angle and the gyro angle. This can be accomplished in one clean line of code as follows: angle_error = Math.IEEEremainder(joystick-gyro,360.0); There's no need for conditional logic. It cleanly handles all input angle ranges for joystick and gyro, including angles greater than 360 degrees and less than -360 degrees. The above assumes that gyro and joystick share the same zero and measurement direction. |
| All times are GMT -5. The time now is 12:29. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi