xlight = cosf(angle_to_light);
ylight = sinf(angle_to_light);
xrotate = A*xlight;// - B*xrepel;// + C*xrandom;
yrotate = A*ylight;// - B*yrepel;// + C*yrandom;
angle_to_rotate = acosf( xrotate/( sqrtf(xrotate*xrotate + yrotate*yrotate) ) );
//printf("xrotate = %f,yrotate = %f,rotate = %f\n",xrotate,yrotate,angle_to_rotate);
if (angle_to_rotate>0) {
set_motors(0,kilo_turn_right);
}
else if (angle_to_rotate<0) {
printf("hello\n" );
set_motors(kilo_turn_left,0);
}
由于某种原因,我从没获得angle_to_rotate的负值。基本上我的代码从不打印“ hello”。 angle_to_light可以是+ ve或-ve弧度吗? acosf如何在c ++中正常工作?请帮助