I suspect that the problem is you're using degrees as your unit of angle, which is not what the cos function is intended for.

http://www.cplusplus.com/reference/clibrary/cmath/cos/