I scanned through the code in the Xbox360 class and didn't really find any reason for needing any custom math. The only methods that need some math are to return the joystick values in polar coordinates instead of the cartesian coordinates (i.e. returning magnitude/angle instead of returning X and Y). There are two things you can do:
- If you don't really need polar coordinates, you can simply remove the methods from the class: GetLeftAngle, GetRightAngle, GetLeftMagnitude and GetRightMagnitude. Then you can remove the reference of custom math. Note: if you think you need polar coordinates because you have a mecanum drive train, you really don't. The WPI library for mecanum support is doing all the math for you. So you can just call the Mecanum_Cartesian method passing it X, Y and rotation.
- If you do really need polar coordinates translation. You can use the built-in math library. I don't see why you need custom math. In any case, I would just use the following macros to translate cartesian coordinates into polar coordinates:
Code:
#define MAGNITUDE(x,y) sqrt(pow(x, 2) + pow(y, 2))
#define RADIANS_TO_DEGREES(n) ((n)*180.0/PI)
// Forward is 0-radian
#define DIR_RADIANS(x,y) ((((x) == 0.0) && ((y) == 0.0))? 0.0: atan2(x, y))
#define DIR_DEGREES(x,y) RADIANS_TO_DEGREES(DIR_RADIANS(x, y))