The equation of the line can be written , where (and is the point we are describing). Then is a vector orthogonal to the line (if , then ), hence the projection of on is the point such that and , i.e. , so and , and the distance between the origin and the line is . This is a useful result to remember.
Using this fact, the exercise is just the verification of a simple trigonometric formula. It is even easier if you rewrite the second equation as (multiplying both sides by ), so that for both lines, so you have to check that . I guess you know how to do this.