UV數據與風速風向數據轉換

package com.qr.util; import java.text.DecimalFormat; /** * //TODO UV數據與風速風向數據轉換 */
public class UVAndSD { /** * UV數據計算速度 */
    public static double vectorToSpeed(double uMs, double vMs) { double windAbs = Math.sqrt(Math.pow(uMs, 2) + Math.pow(vMs, 2)); return windAbs; } /** * UV數據計算風向 */
    public static double vectorToDegrees(double uMs, double vMs) { DecimalFormat df = new DecimalFormat("#.000"); double windAbs = Math.sqrt(Math.pow(uMs, 2) + Math.pow(vMs, 2)); double windDirTrigTo = Math.atan2(uMs / windAbs, vMs / windAbs); double windDirTrigToDegrees = windDirTrigTo * 180 / Math.PI; double windDirTrigFromDegrees = windDirTrigToDegrees + 180; return Double.parseDouble(df.format(windDirTrigFromDegrees)); } }
相關文章
相關標籤/搜索