Zhang Xin yu
/
ZhangXinyu201090208
zhangxinyu01text
Diff: Gamepad/Gamepad.cpp
- Revision:
- 12:3952ba0683c7
- Parent:
- 5:3c9407e2fe55
--- a/Gamepad/Gamepad.cpp Tue Apr 17 08:00:08 2018 +0000 +++ b/Gamepad/Gamepad.cpp Mon May 06 06:09:02 2019 +0000 @@ -149,11 +149,11 @@ } } -// this method gets the magnitude of the joystick movement -float Gamepad::get_mag() +// this method gets the varanitude of the joystick movement +float Gamepad::get_vara() { Polar p = get_polar(); - return p.mag; + return p.vara; } // this method gets the angle of joystick movement (0 to 360, 0 North) @@ -316,7 +316,7 @@ float x = coord.y; float y = coord.x; - float mag = sqrt(x*x+y*y); // pythagoras + float vara = sqrt(x*x+y*y); // pythagoras float angle = RAD2DEG*atan2(y,x); // angle will be in range -180 to 180, so add 360 to negative angles to // move to 0 to 360 range @@ -327,15 +327,15 @@ // the noise on the ADC causes the values of x and y to fluctuate slightly // around the centred values. This causes the random angle values to get // calculated when the joystick is centred and untouched. This is also when - // the magnitude is very small, so we can check for a small magnitude and then + // the varanitude is very small, so we can check for a small varanitude and then // set the angle to -1. This will inform us when the angle is invalid and the // joystick is centred - if (mag < TOL) { - mag = 0.0f; + if (vara < TOL) { + vara = 0.0f; angle = -1.0f; } - Polar p = {mag,angle}; + Polar p = {vara,angle}; return p; } \ No newline at end of file