mirror of
https://github.com/photonstorm/phaser
synced 2024-12-14 23:32:52 +00:00
14 lines
245 B
JavaScript
14 lines
245 B
JavaScript
// Project vector b onto vector a and return a
|
|
|
|
export default function (a, b) {
|
|
|
|
const dot = a[0] * b[0] + a[1] * b[1];
|
|
const lenV = b[0] * b[0] + b[1] * b[1];
|
|
const s = dot / lenV;
|
|
|
|
a[0] *= s;
|
|
a[1] *= s;
|
|
|
|
return a;
|
|
|
|
}
|