Skip to content

外卖卷:非常划算 扫码领劵 省点小钱钱

0

↗️ 向量长度

向量 $a$ 的长度写作: $||a||$

公式

$$ len = \sqrt{x^2 + y^2} $$

代码实现

2D

javascript
function len(x, y) {
  return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
}

1 ~ n 维通用算法

javascript
function len(...args) {
	return Math.sqrt([0, ...args].reduce((t, v) => t + Math.pow(v,2)))
}
最近更新

评论