Say we have an 0XY coordinates plane. We have coordinates of points A(xa, ya), B(xb, yb) forming line. How to find points C and D forming new line so that its center would be in the middle of AB and its length would be some N*K float value:


Let $v$ be $\vec {AB}$ normalized and let $u=v^{\perp}=(-v_y,v_x)$. Then $C=E+\frac 12 NK u$ and $D=E-\frac 12 NK u$, where $E=\frac 12(A+B)$.