I tried some of the formulas answered here, but none of them works within the constraints of my problem.
Here is it:
I got two points - P1 and P2 and a line - [Pa, Pb]. Inbetween these points, I detect a intersection with the line, giving the point P3.
The problem is - I have to find the projected position of P2 into line [Pa, Pb] and this projection needs to be parallel to a 90º world degree angle.
I've got a gif for you guys with two examples:
I've already found P3.
So, with P1, P2, P3 (if there is an interesection) and the direction of the line (Pa - Pb) normalized, I have to find point X