[SOLVED] Vector to Coordinate?

Try

const d = (v1, v2) => ((Math.atan2(v2.x - v1.x, v2.y - v1.y) + Math.PI * 2) % (Math.PI * 2));
const c = (v, a, r) => (new Vector(v.x + Math.sin(a) * r, v.y + Math.cos(a) * r));
const point = (l, n) => (c(l[0], d(...l), n));

To get a point, just do something like

const point1 = new Vector(40, 35);
const point2 = new Vector(50, 35);
point([point1, point2], 5); // x: 45, y: 35

Edit: just tested it, works as intended

3 Likes