Search code examples
mathgeometryline

Drawing a perpendicular line with a midpoint that meets in the middle


I have co-ordinates (x0,y0) and (x1,y1) that define a line of length L. I want to draw a line of length L that is perpendicular to this line such that the midpoint of the new line touches (x0,y0) - so that it forms a T. I need to obtain the co-ordinates (x3,y3) and (x4,y4) of this line.

I know that the slope of the original line is (y1-y0) / (x1-x0) and that the the slope of the new line will be -1 * the inverse of that.

This question is broadly similar (and probably quite simple) to this question:

Drawing line perpendicular to a given line

If I knew x3,y3 then I'd obviously be able to calculate x4,y4 easily, but I'm stumped at how to obtain the co-ordinates x3,y3.


Solution

  • You can do it with similar triangles. Cant draw a pic on here but ends up:

    x3 = x0 - (y1-y0)/2

    y3 = y0 + (x1-x0)/2

    x4 = x0 + (y1-y0)/2

    y4 = y0 - (x1-x0)/2