Skip to content

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

0

📐 向量之间的夹角

公式

$$ \theta = arcos(\frac{\vec a·\vec b}{|\vec a||\vec b|}) $$

对于单位向量

$$ \theta = arcos(\hat a· \hat b) $$

代码参考

typescript
export function includedAngle(a: number[], b: number[]) {
  return Math.acos(dotProduct(a, b) / (len(a) * len(b)))
}

dotProduct: 点乘

add: 加法 a + b

len: 求向量矩阵的长度

最近更新

评论