Explanation of the solution of a geometry question, using analytical geometry and imaginary numbers I came across the following question and its solution a little while ago, but couldn't understand it.
The question is as follows:
You are given a line segment $AB$. Pick a point $M$ outside of $AB$ such that the line from $M$ perpendicular to $AB$ will intersect it in an interior point of the line segment $AB$. We bring segments $AC$ and $BD$ such that $AC$ is perpendicular to $AM$ and $AC=AM$ and $BD$ is perpendicular to $BM$ and $BD=BM$. We also know that $C$, $M$ and $D$ are on the same half plane, as for the line $AB$. Prove that the middle $K$ of the segment $CD$ is a constant point, in other words that it is independent of the position of point $M$.

I initially tried solving it using Euclidean geometry, bringing perpendicular lines from $C$ and $D$ towards $AB$ and working out that triangles $MHB$ and $BZD$ are equal (where $H$ is the point where the line drawn from $M$ perpendicular to $AB$ intersects $AB$), however I didn't succeed in solving it. I then looked at the sample solution, but didn't succeed in understanding it. The sample solution goes as follows:
We have line AB as the axon of the real numbers in the imaginary plane and the middle of AB as the center of the axes. If we have that $M$ is the image of the imaginary number $z$ and the point $B$ is the image of the real number $a$. Then  we have that point $A$ is the image of the real number $-a$. So the vector $\vec{AM}$ corresponds to the imaginary number $z+a$. Since $AC$ is perpendicular to $AM$, $AC=AM$, $(\vec{AM}, \vec{AC})=90$ degrees. So the vector $\vec{AC}$ corresponds to the imaginary number $i(z+a)$. So we have that vector $\vec{OC}=\vec{OA}+\vec{AC}$ in other words that for point $C$, the imaginary number $-a+i(z+a)$ corresponds to it.
With the same thought pattern, but with the observation that $(\vec{BM}, \vec{BD})=-90$, we have that the point D corresponds to the imaginary number $a-i(z-a)$. So we have that the middle $K$ of the segment $CD$ is the image of the imaginary number:
$\frac{z_c+z_d}{2}=\frac{-a+i(z+a)+a-i(z-a)}{2}=ai$
So we have that $K$ isn't dependent of the imaginary number $z$. So that means that $K$ is independent of the position of $M$.
I am familiar with both vectors and imaginary numbers, however I have never seen them being used in this context. Could you please help me understand this solution? In particular I haven't understood what the meaning of the phrase "$A$ is an image of the real number $-a$", or how a vector can correspond to an imaginary number or what $(\vec{AM}, \vec{AC})=90$ means. Could you please explain the solution to me clearly and refer to some resources, for things which you believe I might not know, so that I can understand the concept implicitly? Thanks a lot in advance, for your time and effort. P.s. If I got a term wrong in English, please tell me about it, because I was translating this solution and am not sure if terms I used like "mirror" are correct in English. Thanks again.
 A: I first saw this problem in the book 123 infinity.  You may be able to find the book in PDF.
This is as close as I can remember to Gamgow's explanation:
Without loss of generality we can place $A$ at $1+0i$ and B at $-1 + 0i$
The vector from $M$ to $A$
$AM = A - M$
Rotating 90 degrees clockwise means multiplying the vector by $i.$
$C = A + i(A-M)$
$D$ is a counter clockwise rotation.
$D = B - i(B-M)$
$\frac 12 C + \frac 12 D = \frac 12(A+B) + (A-B)i = 0 + i$
I don't think it actually matters if the line through $M$ perpendicular to $AB$ intersects $AB$ inside of $A$ and $B$
Here is a link with an expanded discussion of the problem.
https://www.mathematicalwhetstones.com/uploads/5/4/9/9/54991295/blog_18_gamows_puzzle.pdf
A: I will try to explain the usage of complex numbers in the context. To each point in the plane $\Bbb C$ there corresponds an affix, a complex number. (This depends on choosing an origin and the axes of coordinates. Let us assume we did it.) For a point $Z$ (capital letter) we denote by $z$ (lower case letter) the corresponding affix in $\Bbb C$. Then the following rather simple ingredients lead to the solution.

*

*A rotation around the origin $0$ by angle $t$ is implemented by multiplying with $e^{it}:=\cos t+i\sin t$. (This number has modulus one, so $z\to e^{it}z$ preserves distances, invariates $0$, is the $t$-rotation for a point on the unit circle since $e^{it}\cdot e^{iu}=e^{i(t+u)}$, and similarly we can argue for the action on points of the circle centered in $0$ of radius $r$.) So this rotation is the map $\Bbb C\to\Bbb C$ given by:
$$z\to e^{it}z\ .$$


*A rotation of angle $t$ around a point (with affix) $a$ is implemented by the map $\Bbb C\to\Bbb C$ given by:$$z\to a + e^{it}(z-a)\ .$$Proof: This is the composition of the three maps: translation of the plane that maps $a\to 0$, rotation of angle $t$ around $0$, translation back mapping $0\to a$. By this, a point $z\in\Bbb C$ is mapped as follows: $z\to z-a$ (translating $a$ to $0$), then $(z-a)\to e^{it}(z-a)$ (rotation as at the first point around $0$ with given angle $t$), and finally translating back, $e^{it}(z-a)\to e^{it}(z-a) + a$.


*In particular a rotation of angle $90^\circ$, i.e. $\pi/2$, is implemented by the multiplication with $e^{i\pi/2}=i$.


*And a rotation of angle $-90^\circ$, i.e. $-\pi/2$, is implemented by the multiplication with $e^{-i\pi/2}=-i$.


*Understanding only the (action of) multiplications with $i$ and $-i$ on $\Bbb C$ are sufficient for the OP.

Let now $a,b,z$ be the affixes of the points $A,B,M$. Then:
$$
\begin{aligned}
c &=a + i(z-a)\ , &&\text{$c$ is $z$ rotated $+90^\circ$ around $a$ },\\
d &=b - i(z-b)\ , &&\text{$d$ is $z$ rotated $-90^\circ$ around $b$ },\\
k &=\frac 12(c+d)
\\
&=\frac 12\Big(\ (a + i(z-a))+(b - i(z-b))\ \Big)\ ,
\end{aligned}
$$
and $z$ cancels in the last expression.
