I am trying to calculate point on a line.
I got the points of the edges and one distance between one edge to the point I want to find (which is B).
A(2,4)
B(x,y)
C(4,32)
The distance between A to B is 5.
How can I calculate Bx and By? using the following equations:
d = Math.Sqr((Bx-Ax)^2 + (By-Ay)^2)
d = Math.Sqr((Cx-Bx)^2 + (Cy-By)^2)
and than compare the equations above.
Here is the equations with the points placed:
5 = Math.Sqr((Bx-2)^2 + (By-4)^2)
23.0713366 = Math.Sqr((4-Bx)^2 + (32-By)^2)
or
Math.Sqr((Bx-2)^2 + (By-4)^2) - 5 = Math.Sqr((4-Bx)^2 + (32-By)^2) - 23.0713377
How can I solve this using VBA?
Thank you!
I won’t solve your equations above because they are an unnecessarily complex way to state the problem (and the existence of a solution is questionable in the presence of rounding), but all the points on the line
A=(Ax,Ay)toC=(Cx,Cy)can be described asB=(Ax,Ay) + t*(Cx-Ax,Cy-Ay)withtbetween0and1.The distance between
BandAis then given byd=t*Sqrt((Cx-Ax)^2+(Cy-Ay)^2), which you can invert to get the propertfor a givend–t=d/Sqrt((Cx-Ax)^2+(Cy-Ay)^2)In your case,
B(t) = (2,4) + t*(2,28),t=5/Sqrt(2^2+28^2) ~ 0.178->B ~ (2,4) + 0.178 * (2,28) ~ (2.356, 8.987).