Trig functions returns unexpected answers

I’m trying to code a holonomic x-drive bot, which uses atan2 to determine the angle of the joystick. My atan2 function returns correct degree and radian values. The example code I’m using for the robot says to do sin(rad - pi/4) and cos(rad - pi/4). Expected return values are -0.707106 and 0.707106 when rad is 0; but the robot returns values of -0.013707 and 0.999906. Any ideas?

If I put sin(0- pi/4) into a calculator while in degrees mode, it gives the values you are getting. This leads me to believe the trig functions are in degrees mode for some reason, which doesn’t make sense. Maybe a different part of your code could be messing it up? A easy solution would be to just use degrees in the trig functions, but it might be better to find why they are accepting degrees instead of radians.

If you are using blocks, trig functions work with degrees, you can see the conversion to radians in the code viewer.


Thanks so much! I’ll have to manually change the values back then.

One more thing, is there a way to enter pi into blocks code? I haven’t found a way other than just approximating it.