在java中将atan值映射为正0-360度

在java中将atan值映射为正0-360度,java,Java,如何在java编程中将获得的角度(sLine)转换为0-360度。 我已经试过了,但没有达到预期的效果 double sLine = Math.toDegrees(Math.atan((cy - start_point_y) / (cx - start_point_x))); sLine = sLine + Math.ceil( -sLine / 360 ) * 360; 这里(cx,cy)和(start_point_x,start_point_y)是两点。试着这样使用: double

如何在java编程中将获得的角度(sLine)转换为0-360度。 我已经试过了,但没有达到预期的效果

double sLine = Math.toDegrees(Math.atan((cy - start_point_y) / (cx - start_point_x)));  
sLine = sLine + Math.ceil( -sLine / 360 ) * 360;
这里(cx,cy)和(start_point_x,start_point_y)是两点。

试着这样使用:

 double angle =  Math.toDegrees(Math.atan2(cy - start_point_y,cx - start_point_x));

if(angle < 0){
    angle += 360;
}
//otherwise use angle 
double angle=Math.toDegrees(Math.atan2(cy-start_point_y,cx-start_point_x));
如果(角度<0){
角度+=360;
}
//否则使用角度
试着这样使用:

 double angle =  Math.toDegrees(Math.atan2(cy - start_point_y,cx - start_point_x));

if(angle < 0){
    angle += 360;
}
//otherwise use angle 
double angle=Math.toDegrees(Math.atan2(cy-start_point_y,cx-start_point_x));
如果(角度<0){
角度+=360;
}
//否则使用角度

谢谢,但我通过检查象限解决了这个问题:)谢谢,但我通过检查象限解决了这个问题:)