当前U为零,V为负值时,风向计算错误

原代码未正确判断上述情况。
This commit is contained in:
donkie 2022-04-02 10:52:59 +08:00 committed by GitHub
parent 0160b96542
commit 508eef029a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -338,18 +338,7 @@ public abstract class DataMath {
if (windSpeed == 0) {
windDir = 0;
} else {
windDir = Math.asin(U / windSpeed) * 180 / Math.PI;
if (U < 0 && V < 0) {
windDir = 180.0 - windDir;
} else if (U > 0 && V < 0) {
windDir = 180.0 - windDir;
} else if (U < 0 && V > 0) {
windDir = 360.0 + windDir;
}
windDir += 180;
if (windDir >= 360) {
windDir -= 360;
}
windDir = (180 + Math.atan2(V, U) * 180 / Math.PI) % 360;
}
return new double[]{windDir, windSpeed};