⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.java

📁 卡耐基.梅隆大学的机器人仿真软件(Redhat linux 9下安装)
💻 JAVA
字号:
package Carmen;/** Carmen class with utilities that provide unit conversion, basic trig, and host information retrieval */public class Util {  public static double getTime() {    return (double)(System.currentTimeMillis() / 1000.0);  }  /** returns the length of hypotenuse of right angled triangle */  public static double hypot(double x, double y) {    return Math.sqrt(x*x+y*y);  }  /** ensures that theta is in the range -PI to PI */  public static double normalizeTheta(double theta) {    int multiplier;        if (theta >= -Math.PI && theta < Math.PI)      return theta;        multiplier = (int)(theta / (2*Math.PI));    theta = theta - multiplier*2*Math.PI;    if (theta >= Math.PI)      theta -= 2*Math.PI;    if (theta < -Math.PI)      theta += 2*Math.PI;        return theta;  }  /** returns host name */  public static String getHostName() {    String hostname = null;    try {      java.net.InetAddress localMachine =	java.net.InetAddress.getLocalHost();	      hostname = java.net.InetAddress.getLocalHost().toString();    }    catch(java.net.UnknownHostException uhe) {      System.err.println("Could not recover hostname.\n"+			 "Is the network functioning properly? Is the"+			 "nameserver working?");      System.exit(-1);    }    return hostname;      }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -