Clear Filters
Clear Filters

Determining the coordinates of a node between two known nodes and knowing the distances between the known nodes

1 view (last 30 days)
Hi! This may seem like a rather trivial question. Do you know how to determine the coordinates of a node C knowing node A, node B, distance AC and distance CB?
At the moment I can use these two equations:
C = [x, y, z]; %unknown
A = [x_A, y_A, z_A];
d1 = (x-x_A)^2;
d2 = (y-y_A)^2;
d3 = (z-z_a)^2;
d_AC = sqrt(d1 + d2 + d3);
B = [x_B, y_B, z_B];
d4 = (x_B-x)^2;
d5 = (y_B-y)^2;
d6 = (z_B-z)^2;
d_CB = sqrt(d4 + d5 + d6);
A third equation is missing. At the moment I have no idea, and I don't know if it is possible to determine the coordinates directly on matlab.

Accepted Answer

Matt J
Matt J on 13 Jan 2024
Edited: Matt J on 13 Jan 2024
Assuming the nodes form a straight line,
C = A + (B-A)*d_AC/(d_AC+dCB)

More Answers (2)

Torsten
Torsten on 13 Jan 2024
There is only a unique solution for this problem if AC + CB = AB. In all other cases, you either get no solution (AC + CB < AB) or infinitly many solutions (AC + CB > AB).
  2 Comments
Matt J
Matt J on 13 Jan 2024
Edited: Matt J on 13 Jan 2024
or infinitly many solutions (AC + CB > AB).
Wouldn't there be 2 solutions, assuming A~=B? The intersection of the circles of radii AC and BC?
Torsten
Torsten on 13 Jan 2024
Edited: Torsten on 13 Jan 2024
Not in 3d where spheres intersect. And this is reflected by having two equations for three unknowns.

Sign in to comment.


Hassaan
Hassaan on 13 Jan 2024
function C = findPointC(A, B, d_AC, d_CB)
% Define the system of equations
function F = distanceEquations(C)
F(1) = (C(1) - A(1))^2 + (C(2) - A(2))^2 + (C(3) - A(3))^2 - d_AC^2;
F(2) = (C(1) - B(1))^2 + (C(2) - B(2))^2 + (C(3) - B(3))^2 - d_CB^2;
end
% Initial guess (can be changed based on the problem context)
initialGuess = (A + B) / 2;
% Solve the equations
C = fsolve(@distanceEquations, initialGuess, optimoptions('fsolve', 'Display', 'off'));
end
You can use this function by passing the coordinates of points A and B, and the distances dAC​ and dCB​. Keep in mind that this approach might find one of the possible solutions or may fail if the distances provided are not physically consistent with the positions of A and B.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!