0
A
回答
1
爲了避免問題360/0過渡,你可以使用一個條件佔週期性
if (Cos(Bearing) * Cos(POI) + Sin(Bearing) * Sin(POI) > Cos(Threshold)) then
POI direction lies in range Bearing +- Threshold
0
這裏是我的解決方案現在。在努力簡化它。歡迎提出建議。
public static boolean isBearingWithinRange(double heading, double alertHeading, double threshold) {
boolean status = false;
double leftThresholdMin = heading - threshold;
double leftThresholdMax = FULL_CIRCLE;
double rightThresholdMin = 0.0d;
double rightThresholdMax = 0.0d;
double total = heading + threshold;
if(total > FULL_CIRCLE) {
rightThresholdMax = threshold - (FULL_CIRCLE - heading);
if((alertHeading >= leftThresholdMin && alertHeading <= leftThresholdMax) ||
(alertHeading >= rightThresholdMin && alertHeading <= rightThresholdMax)) {
status = true;
}
} else if(heading < threshold) {
double diff = (threshold - heading);
leftThresholdMin = FULL_CIRCLE - diff;
rightThresholdMax = threshold + heading;
if((alertHeading >= leftThresholdMin && alertHeading <= leftThresholdMax) ||
(alertHeading >= rightThresholdMin && alertHeading <= rightThresholdMax)) {
status = true;
}
} else {
rightThresholdMax = heading + threshold;
if(alertHeading >= leftThresholdMin && alertHeading <= rightThresholdMax) {
status = true;
}
}
return status;
}
相關問題
- 1. 速度計算範圍速率和軸承速率
- 2. ZedGraphControl軸值範圍
- 3. 在日期範圍內計算天數?
- 4. 在另一個範圍內計算範圍的出現次數
- 5. 如果值在範圍內則顯示範圍否則如果值小於或大於範圍顯示'$'
- 6. 如何計算IP範圍
- 7. 如何計算一個範圍內的平均值psql
- 8. 如何計算範圍內功能的最大值?
- 9. 計算的值在Excel範圍內使用
- 10. 計算相對日期範圍內的值的最大值
- 11. 計算日期範圍內的天數
- 12. 計算範圍內的數字
- 13. Excel按日期範圍計算日期範圍內的不同值
- 14. 如何計算斜邊和軸承
- 15. 從GPS座標計算Esri地圖範圍
- 16. 熊貓在x軸範圍內的boxplot
- 17. MySQL在任何範圍內的第一次佔用範圍內計數結果
- 18. 確定範圍內的組變量的閾值
- 19. 擊+計算報警如果閾值是下最小
- 20. 閾值數據和計算比值比
- 21. 使用範圍內的所有值計算函數?
- 22. VBA替換範圍內的函數公式與其計算值
- 23. 計算特定範圍內的行數,最大值後
- 24. 計算特定範圍內的值的發生(Excel)(無VBA)
- 25. 更高效的查詢來計算組範圍內的值
- 26. 計算多個範圍內重複值的百分比
- 27. 計算可互換範圍內的平均值?
- 28. 閾值算法
- 29. 實體框架:如何計算其他日期範圍內的日期範圍
- 30. 存儲器範圍計算
所以你需要找到兩個軸承(角度)的差異? – MBo
是的,類似的東西。我需要檢查POI是否在x1,x2的範圍內。 – neilQ5