【发布时间】:2022-12-02 00:54:15
【问题描述】:
I want to ensure the angle h_ur is between 0 to 360 degrees.
h_ur <- atan2(b, a)*(180.0/pi)
but for the sake of the question, I have simplified h_ur as following:
h_ur <- -5
if (h_ur > 360){
h <- h_ur - 360
} else if (h_ur < 0){
h <- 360 + h_ur
} else {
h <- h_ur
}
print(h)
However, this code would only work if the h_ur is between 720 and 360, and 0 and -360.
- How can I alter the code to ensure it would work even if
h_uris outside this range? - Is there a more elegant way to do this?
【问题讨论】: