Iam writing a program for my senior project its a program to input the current coordinates and the destination coordinates and output the compass angle that the user should take, put the program is giving me this errors:
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(545): could be 'long double atan(long double)'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(497): or 'float atan(float)'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(109): or 'double atan(double)'
1> while trying to match the argument list '(int)'
1>c:\users\mohd\documents\visual studio 2008\projects\cordinates angle\cordinates angle\cordinates.cpp(19) : error C2668: 'atan' : ambiguous call to overloaded function
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(545): could be 'long double atan(long double)'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(497): or 'float atan(float)'
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\math.h(109): or 'double atan(double)'
this is my codes
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include<iostream>
#include<string>
#include <stdio.h>
#include <math.h>
using namespace std;
float getAngle(int x1,int y1,int x2,int y2)
{
float angle;
if(x2>x1)
{
if(y2>y1)
angle=atan((x2-x1)/(y2-y1));
else if(y1>y2)
angle=(atan((y1-y2)/(x2-x1)))+90;
}
else if(x1>x2)
{
if(y2>y1)
angle=(atan((x1-x2)/(y1-y2)))+180;
else if(y1>y2)
angle=(atan((x1-x2)/(y2-y1)))+270;
}
else if(x1=x2)
{
if(y2>y1)
angle=0.0;
else if(y1>y2)
angle=180.0;
}
else if(y1=y2)
{
if(x2>x1)
angle=90.0;
if(x1>x2)
angle=270.0;
}
return angle;
}
int main()
{
int x1, x2, y1, y2;
float angle;
cout<<"Enter the cordinates of your point: ";
cin>>x1>>y1;
cout<<"Enter the cordinates of the distination point: ";
cin>>x2>>y2;
angle=getAngle(x1,y1,x2,y2);
cout<<"The angle is "<<angle<<endl;
return 0;
}
|
thank you