Get the vector of the line (marron/yellow) for this example the line has coords of ((1,2) (4,4))
v = (x2-x1), (y2-y1) = (3, 2))
v(perp) = (-2, 3) or (2, -3)
To create a line that starts an one of the points, say (1, 2) to get the end point add the v(perp) to the start point (1-2, 2+3) or (-1, 5). If you want a longer or shorter line scale the vector.
You can also use unit vector and magnitude but this should be easier. Pull out your Calculas II textbook or search the web for vector math.