This is basic graphics geometry and/or trig, and I feel dumb for asking it, but I can\'t remember how this goes. So:
To all those poor souls looking for a concrete example using vectors... here I build upon Gareth's answer.
You have a vector from p to r (from 0,0 to 50,-50) and another point, q, which is at (50, 0). The right-angle intersection of q and the vector from p to r is { x: 25. y: -25 } and is derived with the following code.
const p = [0, 0];
const r = [50, -50];
const q = [50, 0];
const l = math.add(p, r);
const m = math.dot(math.subtract(q, p), r) / math.dot(r, r);
console.log('intersecting point', math.multiply(l, m));