hi,
im trying to make atanf2 function (float MyArcTangent(float y, float x);) with atanf function (..).
But im having problem with the autput values, i cant seem to find out whats wrong
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <iostream>
#include <cmath>
using namespace std;
float theta;
void MyArcTangent(float y, float x);
int main()
{
MyArcTangent( 4, 2 );
MyArcTangent( 5, -1 );
MyArcTangent( -4, -6 );
MyArcTangent( -6, 4 );
}
void MyArcTangent(float y, float x)
{
if( x > 0 )
{
theta = atanf(y/x);
}
else
theta = atanf(y/x) + 180.0f;
cout << "MyArcTangent( " << y << ", " << x << ") = " << theta << endl;
}
|
i should get these values:
MyArcTangent( 4, 2) = 63.4671
MyArcTangent( 5, -1) = 101.27
MyArcTangent(-4, -6) = 213.707
MyArcTangent(-6, 4) = -56.3385
but instead, i get 1.10715, 178.672,...
ty for all the help