📄 angle.java
字号:
/**
* 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -