angle.java
来自「一个飞机调度员模拟训练程序,可以添加跑道数量,控制飞机飞行的速度.默认的密码可以」· Java 代码 · 共 56 行
JAVA
56 行
/**
* A class providing a number of functions for calculating with angles.
*
* @author James M. Clarke
* @version 03/02/2007
*/
public abstract class Angle
{
/**
* Finds the angle clockwise between two angles
*
* @param angle1 the starting angle
* @param angle2 the finishing angle
* @return the angle clockwise between the two angles, measured in radians
*/
public static float diffClockwise(float angle1, float angle2)
{
//Find the angle (clockwise) between two angles
angle1 = normal(angle1);
angle2 = normal(angle2);
if (angle1 < angle2) { return angle2-angle1; }
else { return (float) (2*Math.PI)-(angle1-angle2); }
}
/**
* Finds the angle anticlockwise between two angles
*
* @param angle1 the starting angle
* @param angle2 the finishing angle
* @return the angle anticlockwise between the two angles, measured in radians
*/
public static float diffAnticlockwise(float angle1, float angle2)
{
//Find the angle (clockwise) between two angles
angle1 = normal(angle1);
angle2 = normal(angle2);
if (angle1 < angle2) { return (float) (2*Math.PI)-(angle2-angle1); }
else { return angle1-angle2; }
}
/**
* Converts an angle to an angle in the same direction that is between 0 and 2PI radians.
*
* @param angle the angle to be converted
* @return the equivalent angle between 0 and 2PI radians
*/
public static float normal(float angle)
{
//Make sure that the angle is between 0 and 2*PI
if ( angle > (2 * ((float) Math.PI))) { angle = angle - (2 * ((float) Math.PI)); angle = normal(angle);}
if ( angle < (0F * ((float) Math.PI))) { angle = angle + (2 * ((float) Math.PI)); angle = normal(angle);}
return angle;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?