Angle Between函数–您的Vector对象应具有一个以单个Vector对象作为参数的“ angleBetween”函数。该函数应返回一个标量值,该标量值是“ this”向量和参数Vector之间的角度(弧度)。
这是我需要通过的茉莉花测试:
describe("Angle between", function () {
var vector, secondVector, angleBetween;
vector = new Vector(30, 40, 0);
secondVector = new Vector(-40, 30, 0);
angleBetween = secondVector.angleBetween(vector);
it("Result is PI/2", function () {
expect(angleBetween).toBeCloseTo(Math.PI / 2, 1);
});
});
这是我到目前为止尝试过的,但是没有任何效果。
angleBetween(pVector) {
return this.dotProduct(pVector) * Math.cos(0);
}