The goal is to get the points, p1’ and p2’ (green), from the initial points, p1 and p2 and their respective directional vectors, v1 and v2, which are unit vectors.

Multiplying v1 and v2 by the offset distance d won’t work (cf. example). The distance d is measured perpendicular to the line l. Both vectors are not perpendicular to l, which means that there magnitude must be bigger or smaller than d, depending on their angles to the line l!

Above you can see the scaled vector v1’ with a magnitude of d. It doesn’t reach p1’!