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

3 次查看(过去 30 天)
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.

采纳的回答

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

更多回答(2 个)

Torsten
Torsten 2024-1-13
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 个评论
Matt J
Matt J 2024-1-13
编辑:Matt J 2024-1-13
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?

请先登录,再进行评论。


Hassaan
Hassaan 2024-1-13
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.

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by