Please help. I am trying to use sqrt, and atan but can only successfully compile when I pass in actual numbers instead of variables (see code below). I am wondering if it is something to do with needing to use -lm when compiling (I have seen this on a number of posts) but I don’t know how or where to put it!
#include math.h
void calcVelAndHdg(double northV, double eastV, double upV){
double vel2D, vel3D, hdg2D, tmp2D, tmp3D;
tmp2D = pow(northV,2) + pow(eastV,2);
tmp3D = pow(upV,2) + tmp2D;
vel3D = sqrt(tmp3D);
vel2D = sqrt(tmp2D);
tmp2D = northV/eastV;
hdg2D = atan(tmp2D);
printf("2D velocity=%f 3D veloocity=%f 2D heading=%f
\r",
vel2D, vel3D, hdg2D);
}
PLEASE HELP! Thanks