I am a computer programmer and need to find the x and y coordinate of a point that is a defined perpendicular distance from a midpoint. For reference, I have tried to attached an image for reference.
X1, Y1, D, X2, Y2 will be given. I need to find X3, Y3. The shorter line, will always be perpendicular from the larger line and will always intersect the midpoint between (x1, x2) and (x2, y2). I have been struggling with this a while and cannot figure it out. Any help would be greatly appreciated.

The midpoint is the average of the two endpoints: $$ (\frac{x_1+x_2}{2},\frac{y_1+y_2}{2}). $$ If I understand correctly, you want to move from this midpoint a distance $D$ in a direction perpendicular to the line joining points 1 and 2. The direction from 2 to 1 is given by the vector $$ (x_1-x_2,y_1-y_2). $$ A vector perpendicular to this one is $$ (y_1-y_2,x_2-x_1). $$ We want a vector of this (or the opposite) direction and length $D$ attached to the midpoint, so the final point will be $$ (x_3,y_3) = (\frac{x_1+x_2}{2},\frac{y_1+y_2}{2}) \pm \frac{D}{\sqrt{(y_1-y_2)^2+(x_2-x_1)^2}}(y_1-y_2,x_2-x_1). $$