package com.gyee.runeconomy.service.WindDirection; public class Deviation { // 计算风速偏差率 public static double calculateSpeedDeviation(double fanSpeed, double towerSpeed) { if (towerSpeed == 0) { throw new IllegalArgumentException("Tower speed cannot be zero."); } return Math.abs(towerSpeed - fanSpeed) / towerSpeed * 100; } // 计算风向差值 public static double calculateDirectionDeviation(double fanDirection, double towerDirection) { double difference = Math.abs(towerDirection - fanDirection); if (difference > 180) { difference = 360 - difference; } return difference; } }