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. Sumif在計算範圍內
- 2. 速度計算範圍速率和軸承速率
- 3. 計算範圍內出現的值
- 4. 計算不同值範圍
- 5. ZedGraphControl軸值範圍
- 6. 在日期範圍內計算天數?
- 7. 在另一個範圍內計算範圍的出現次數
- 8. 計算的值範圍在百分之
- 9. 計算向量的閾值
- 10. 如果值在範圍內則顯示範圍否則如果值小於或大於範圍顯示'$'
- 11. 如何計算IP範圍
- 12. 如何計算範圍內功能的最大值?
- 13. 如何計算任意範圍內的中間值
- 14. 如何計算一個範圍內的平均值psql
- 15. 範圍函數來計算結果
- 16. 在模式範圍內計算平均值
- 17. 用於在數值範圍內計數子串的算法
- 18. 計算的值在Excel範圍內使用
- 19. 計算相對日期範圍內的值的最大值
- 20. Javascript承諾結果範圍
- 21. 計算日期範圍內的天數
- 22. 計算時間範圍內的天數?
- 23. 計算日期範圍內的天數
- 24. 計算範圍內的數字
- 25. 如何計算斜邊和軸承
- 26. Angular2 ng如果在承諾範圍內更改,則不更新
- 27. Excel按日期範圍計算日期範圍內的不同值
- 28. 從GPS座標計算Esri地圖範圍
- 29. 計算範圍的唯一值
- 30. 計算netcdf 3D變量的值範圍
所以你需要找到兩個軸承(角度)的差異? – MBo
是的,類似的東西。我需要檢查POI是否在x1,x2的範圍內。 – neilQ5