Let (x0, y0) be the coordinates of the green dot. Assuming this is really a square (i.e., all sides are equal) and the origin is in the lower-left corner, the equation of the diagonal is y = x. The equation of the perpendicular to the diagonal that passes through the green dot is y - y0 = -(x - x0), i.e., y = -x + x0 + y0. Solving this system for x gives you x = (x0 + y0) / 2 = y.
If you want to have "real fun!", re-word your problem this way:Code:A B a b P x D x C
Square ABCD has side lengths = x.
Point P is inside, a from side AB, b from side AD.
What is the distance from P to diagonal BD in terms of a,b,x?