首页 > 解决方案 > 如何将 X 和 Y 速度转换为一个速度

问题描述

我将如何将 X 和 Y 速度转换为一个速度?我指的不是角度,而是速度。

var velocityX = some velocity;
var velocityY = some velocity;

// Convert the two X and Y velocities to one velocity

标签: javascriptmathvector

解决方案


全力以赴Math.hypot

newVelocity = Math.hypot(velocityX, velocityY);

推荐阅读