I am attempting to code my mecanum wheel bot to be able to head any direction. This involves the atan function, as far as I have been able to tell. When I enter two values into the atan function, the numbers returned are completely incorrect. For example, atan(100/-10) should return ~-1.47. VexCode returns -84. As another example, atan(86/81) should give ~0.815. VexCode returns 45. Left and right directions return zero, no matter what. Is there a workaround? Am I doing something wrong? Code is in attachment.

When using blocks, the return value of `atan`

is in degrees (as the following math shows with the examples that *you* provided):

Example block code:

VEXcodeâ€™s Blocks-to-Text (python):

```
brain.screen.print(math.atan(15) / math.pi * 180)
```

As you can see, there is an internal conversion to degrees.

You can invert the math if you want the value in radians (divide by `180/Ď€`

or multiply by `Ď€/180`

).

That makes sense, thanks. Do you know why the left and right directions return zero? After 45 degrees in either direction, it will switch to zero.

Could you please clarify â€śleft and right directionsâ€ť? I was probably missing something, but I didnâ€™t quite understand how it relates to the code.

The (roughly marked) red sections return zero no matter what

Expected controller points where the return value is 0:

If the position of `axis4`

is `0`

, there may be a ** ZeroDivisionError** caused by (you guessed it), dividing by zero. It doesnâ€™t explain why you get 0 anywhere in the range you specified though. I suggest converting to a text project so that you can have a more dynamic output when debugging.

Any errors will show in this panel,

and you can print some test cases there too (such as printing

`axis3/axis4`

in the while loop).
I got it to return degrees 0-360. It took 111 blocks. Not ideal, but it works.

The joystick also has to be along the edge.