In your existing code your angles would appear to be in degrees. For the C++ trigonometry functions (actually for most programming languages) the angles need to be expressed in radians. Bear that in mind when following wayfaerer's lead.