javascript - 如何将 X 和 Y 速度转换为一个速度
问题描述
我将如何将 X 和 Y 速度转换为一个速度?我指的不是角度,而是速度。
var velocityX = some velocity;
var velocityY = some velocity;
// Convert the two X and Y velocities to one velocity
解决方案
全力以赴Math.hypot
。
newVelocity = Math.hypot(velocityX, velocityY);
推荐阅读
- android - 如何将文件发送到 REST 服务?
- firebase - 如何将我在firebase云函数中获得的键值对对象的值设置为零(快照)
- javascript - JS:数据表多行消息
- python - GMAIL API:使用 gmail api 将所有客户端 gmail 消息转发到 gmail 地址
- python - 如何在Python中找到具有两个元素的数组的平均值?
- django - 在Django的Wkhtmltopdf中渲染静态文件
- javascript - 如何使用jquery在asp中绑定表中的数据?
- python - 如何使用 mypy 导出函数签名?
- javascript - 如何使用键或值中的变量设置反应状态
- c++ - 查找字符串 C++ 的隐藏排列