Update snippet descriptions
This commit is contained in:
@ -3,12 +3,11 @@ title: vectorAngle
|
||||
tags: math,beginner
|
||||
---
|
||||
|
||||
Returns the angle (theta) between two vectors.
|
||||
Calculates the angle (theta) between two vectors.
|
||||
|
||||
- Use `Array.prototype.reduce()`, `Math.pow()` and `Math.sqrt()` to calculate the magnitude of each vector and the scalar product of the two vectors.
|
||||
- Use `Math.acos()` to calculate the arccos and get the theta value.
|
||||
|
||||
|
||||
```js
|
||||
const vectorAngle = (x, y) => {
|
||||
let mX = Math.sqrt(x.reduce((acc, n) => acc + Math.pow(n, 2), 0));
|
||||
|
||||
Reference in New Issue
Block a user