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));
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM