# Thread: Finding Point along square's diagnal

1. ## Finding Point along square's diagnal

Hello, Im stuck on a maths problem for an application im working on.
I have made a diagram to explain. I have the x/y coordinates for the green dot, and need to then find the coords of the red dot. If sombody could direct me as to how to find this i would be very grateful.

2. ## Re: Finding Point along square's diagnal

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.

3. ## Re: Finding Point along square's diagnal

Code:
A                         B
a

b   P

x

D           x             C
If you want to have "real fun!", re-word your problem this way:
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?

Spoiler:

distance P to BD = SQRT(u^2 - v^2)
where:
u = SQRT[b^2 + (x-a)^2]
v = (x + b - a) / SQRT(2)