30秒学会 JavaScript 片段 – vectorAngle
Returns 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.
继续阅读 30秒学会 JavaScript 片段 – vectorAngle