感谢NEZ库提供的思路

This commit is contained in:
yhh
2021-06-11 16:20:01 +08:00
parent 44e2ca07e5
commit 219b90fc5d
10 changed files with 204 additions and 21 deletions

View File

@@ -381,6 +381,16 @@ module es {
return this.repeat(this.approach(start, start + deltaAngle, shift), 360);
}
/**
* 将 Vector 投影到另一个 Vector 上
* @param other
*/
public static project(self: Vector2, other: Vector2) {
let amt = Vector2.dot(self, other) / other.lengthSquared();
let vec = new Vector2(amt * other.x, amt * other.y);
return vec;
}
/**
* 通过将偏移量(全部以弧度为单位)夹住结果并选择最短路径,起始角度朝向终止角度。
* 起始值可以小于或大于终止值。