This construction worksFirst case: if point $P$ islies outside line $AB$. We want, here's how to findconstruct $H$ on $AB$ such that $PH\perp AB$.
SupposeWe can suppose WLOG that $PA>PB$ (if $PA=PB$ then $H$ is the midpoint of $AB$).
Construct $C$ on ray $AP$ such that $AC=AP+BP$. Construct $D$ on ray $AB$ such that $AD=AP-BP$. Construct $E$ on ray $AB$ such that $AE=2AB$. Join $CE$ and construct the line through $D$ parallel to $CE$, intersecting line $AP$ at $F$.
It is easy to show that $$ AF={AP^2-BP^2\over2AB}. $$ But, on the other hand: $$ AH={AB\over2}+{AP^2-BP^2\over2AB}. $$ Hence, if $M$ is the midpoint of $AB$, we have $MH=AF$ and point $H$ can thus be constructed.
Second case: if point $P$ lies on line $AB$, then take any point $Q$ outside $AB$ and construct $H$ on $AB$, as shown above, such that $QH\perp AB$. Construct then the midpoint $M$ of $PQ$ and point $H'$, symmetric of $H$ with respect to $M$. Line $PH'$ is then the required perpendicular, because $QHPH'$ is a parallelogram.
