How to find the angle of reflection given 2 points and a mirror?

979 Views Asked by At

I'm pretty new to the Mathematics section of StackExchange and need some guidance on some math for a 2d topdown game I am making. In my game there is an Archer boss, who can shoot reflective arrows, which reflect on the walls similar to light i.e. the angle of incidence is the angle of reflection. In order to make the boss smart I want to add a system which shoots an arrow to the wall which reflects to the player. All I need is to find the angle to shoot at so that it reflects to the player (i.e. angle A in the figure). The actual angle I need refers to angle relative to a line drawn from the player towards the top of the stage, the angles increase clockwise (so 0 deg is top, 90 deg is right, 270 is left etc). This is not needed as I can adjust.

What is given for the function is the boss' and player's coordinates and their height towards the nearest wall (Remember that this is a 2d topdown game therefore height towards wall is the shortest distance towards the wall). Using these parameters how to find angle A in the figure?

Here is the image

1

There are 1 best solutions below

4
On BEST ANSWER

Just reflect $B$ in the mirror to get a point $B'$ lying in the shaded area of the diagram. Now draw a straight line from $A$ to $B'$. Where this line crosses the plane of the mirror is your point $C$.