Let's say that we have three points: $p = (x_p,y_p)$, $q = (x_q,y_q)$ and $a = (x_a,y_a)$. How can i find point $b$ which is reflection of $a$ across a line drawn through $p$ and $q$? I know it's simple to calculate, when we have $p$, $q$ etc. But I want to do this in my program, and I'm not sure, how to compute this.
OK, I've found solution by myself (but answers in this topic really helped me).
Suppose, that we have a line $Ax+By+C=0$, and $A^2+B^2 \not= 0$. $M (a,b)$ reflection across the line is point: $M' (\frac{aB^2-aA^2-2bAB-2AC}{A^2+B^2}, \frac{bA^2-bB^2-2aAB-2BC}{A^2+B^2})$
In my case, we don't have line, but only 2 points. How we can find $A,B,C$? It's simple:
Let's say, that $p=(p_x,p_y)$ and $q = (q_x,q_y)$. Line equation is: $(y-p_y)(q_x-p_x) - (q_y-p_y)(x-p_x) = 0$
After some calculations we have: $y(q_x-p_x) - x(q_y-p_y) - (p_y(q_x-p_x)+p_x(p_y-q_y)) = 0$
So: $A = p_y-q_y$, $B = q_x-p_x$ and $C = -p_y(q_x-p_x)-p_x(p_y-q_y)$.
That's all.