Find reflection vector of 2 lines in 2D with General form

57 Views Asked by At

I am having problems computing the reflection of 2 lines using the General form (Ax + By + C = 0). I am currently using the following method:
We have lines a and b;
vector_x = dot_product(a.colinear().normalize(), b.colinear().normalize());
vector_y = sqrt(1-vector_x^2);

In words that would look like:
vector_x is equal to the dot product of the normalized colinear vectors of both lines
vector_y is equal to the square root of 1 - vector_x ^ 2

This outputs a vector that needs to be rotated 180 - angleToXAxis*2 degrees

In the following picture the green line acts as a mirror for the blue line which needs to be reflected. The output is the vector near the (0,0) point (I can't post images so you would have to use the link):
Graph

I am currently struggling to rotate the vector so I would appreciate if someone can provide a formula for it. Also if someone knows a better way of doing it suggestions are very welcome!