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.