Here's the same code in an online shell, so you can see that it actually returns those values.推荐答案找到了解决方案.看来问题与精度有关.如果我确定$dist在[-1,1]范围内,则可以正常运行:Found the solution. It seems that the problem is related to precision. If I make sure that $dist is within [-1,1] range, it works fine:$dist = acos(min(max($dist,-1.0),1.0));工作示例: https://3v4l.org/dlunK 这篇关于在某些情况下,acos(1)返回NAN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-19 22:05