-
Notifications
You must be signed in to change notification settings - Fork 2
/
lib.js
26 lines (26 loc) · 854 Bytes
/
lib.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
*
* @param {[number, number]} origin
* @param {[number, number]} windVector
* @param {number} time
*/
export function createWindPolygon(origin, windVector, time) {
const vOrigin = new Vector(...origin);
const vWind = new Vector(...windVector).sub(vOrigin);
const rotWind = vWind.rotateDegrees(90);
// WindShift
const windShift = rotWind.clone().rotateDegrees(180).mulScalarSelf(0.5);
// FIRST BASEPOINT
const basePoint1 = vOrigin.clone().addSelf(windShift);
// SECOND BASEPOINT
const basePoint2 = vOrigin.clone().addSelf(windShift).addSelf(rotWind);
const targetPoint1 = basePoint1.add(vWind.mulScalar(time));
const targetPoint2 = basePoint2.add(vWind.mulScalar(time));
const polygon = [
basePoint2.toArray(),
basePoint1.toArray(),
targetPoint1.toArray(),
targetPoint2.toArray(),
];
return polygon;
}