account for rotation when moving the crop region

This commit is contained in:
Ryan Di 2024-10-08 12:04:51 +08:00
parent 80ff1562b8
commit e30fd9960d
2 changed files with 87 additions and 7 deletions

View file

@ -139,3 +139,10 @@ export const vectorNormalize = (v: Vector): Vector => {
return vector(v[0] / m, v[1] / m);
};
/**
* Project the first vector onto the second vector
*/
export const vectorProjection = (a: Vector, b: Vector) => {
return vectorScale(b, vectorDot(a, b) / vectorDot(b, b));
};