the part that throws me off is the line where |b|^2 comes in, I can understand how they used it to get the solution but I don't understand where it actually came from.

the part that throws me off is the line where |b|^2 comes in, I can understand how they used it to get the solution but I don't understand where it actually came from.

I believe that in my memory this is where it comes from
.
This comes from the angle for vectors.
There, what you do is replace with and then what you will have is
.
The interesting part is that since lies in the same direction of then which leads to beccause . Note this is for two vectors going in the same direction.
For vectors going in the opposite direction
.