球与球碰撞
我阅读了页面球与球碰撞 - 检测和处理并且我对resolve_collision 的代码有点困惑。我得到了一切,除了 1.0f + Constants.restitution 是什么?什么是 1.0f,什么是 Constants.restitution?
I read the page Ball to Ball Collision - Detection and Handling and am a bit confused about the code for resolve_collision. I get everything except what is 1.0f + Constants.restitution? What is 1.0f and what is Constants.restitution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1.0f
是浮点1.0
的文字。在 Java 中,1.0
默认为double
类型,因此作者通过添加f
显式使其成为float
> 之后标记。Constants.restitution
据称代表恢复系数,通常是物理学中的e或Cr。这定义了球撞击地板或另一个球后的弹跳程度。尽管他没有在他提供的代码中显示它,但它可能在某处声明为The
1.0f
is the literal for a floating point1.0
. In Java,1.0
will default to typedouble
, so the author is explicitly making it afloat
by adding thef
flag afterwards.Constants.restitution
supposedly represents the coefficient of restitution, which is usually an e or Cr in physics. This defines how much a ball bounces once it hits the floor or another ball. Though he doesn't show it in the code he provided, it is probably declared somewhere as恢复系数是 0 到 1 之间的数字,表示碰撞时的弹性大小。 0 表示接触的物体将粘在一起,1 表示它们将以完全弹性的方式弹开(恢复所有速度)。
尝试谷歌搜索恢复系数,其余的就会随之而来。
The coefficient of restitution is a number between 0 and 1 that indicates the amount of elasticity in the collision. A 0 means the contacting bodies will stick together, and a 1 means they will bounce off in a perfectly elastic fashion (recovering all their speed).
Try Googling coefficient of restitution and the rest will follow.