So im trying to find the distance between 2 points ( with an x,y coordinate). So im trying to use the Pythagorean theorem. But im getting errors and not sure how to fix it.
im using this formula
http://www.purplemath.com/modules/xyplane/dist06.gif
heres the code that gives me the error.
1 2 3 4 5 6 7 8 9 10 11
|
double distance(Node current, Node goal){
int xA = current.x;
int yA = current.y;
int xB = goal.x;
int yB = goal.y;
double x =pow(xB-xA,2);
double y = pow(yB-yA,2);
double dist = sqrt(x+y);
return dist;
}
|
here's the error i get
1>------ Build started: Project: sdl, Configuration: Debug Win32 ------
1> sdl_tut_pt2.cpp
1>c:\users\sean\documents\visual studio 2010\projects\sdl\sdl\sdl_tut_pt2.cpp(172): error C2668: 'pow' : ambiguous call to overloaded function
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(583): could be 'long double pow(long double,int)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(535): or 'float pow(float,int)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(497): or 'double pow(double,int)'
1> while trying to match the argument list '(int, int)'
1>c:\users\sean\documents\visual studio 2010\projects\sdl\sdl\sdl_tut_pt2.cpp(173): error C2668: 'pow' : ambiguous call to overloaded function
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(583): could be 'long double pow(long double,int)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(535): or 'float pow(float,int)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\math.h(497): or 'double pow(double,int)'
1> while trying to match the argument list '(int, int)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========