将坐标转化为与X轴正半轴夹角模板

 

 

 


//还需加PI 和 mabs 函数

double
chg(double x,double y) { double tmps; if(mabs(x-0)<1e-8) { if(y>0) tmps=90.0; else tmps=270.0; } else { tmps=y/x; //将这个点的斜率求出来 if(mabs(y-0)<1e-8) { if(x>0) tmps=0.0; else tmps=180.0; } else { tmps=atan(tmps);//求出角度 tmps=(180.0/PI)*tmps; if(y*x > 0&&y<0) tmps += 180.0; if(y*x<0) { tmps*=-1; if(x<0) tmps=180.0-tmps; else { tmps=360.0-tmps; } } } } return tmps; }

 

posted @ 2013-10-02 21:56  chenhuan001  阅读(194)  评论(0编辑  收藏  举报