【发布时间】:2018-09-06 03:34:42
【问题描述】:
我真的不明白为什么这个表达式只有在
acceleration.module - Ambient.friction = 0
:
double x = (speed.module * speed.direction.x()) + ((acceleration.module-Ambient.friction) * acceleration.direction.x())*time;
此外,如果我像这样添加穿刺术:
double x = ((speed.module * speed.direction.x()) + ((acceleration.module-Ambient.friction) * acceleration.direction.x()))*time;
它又给了我一个 NaN 错误。
【问题讨论】:
-
使用调试器进行调试
-
请发布minimal reproducible example,其中包含所有带有硬编码值的变量的定义。这将使我们更容易为您提供帮助。
-
@user6690200 一个(或多个)操作数是 NaN。它不能是字符串;这不是 JavaScript。
-
@AndyTurner 这不是 JavaScript!有规矩!
-
@AndyTurner 我的错...这可能会有所帮助stackoverflow.com/questions/2618059/in-java-what-does-nan-mean