필터 지우기
필터 지우기

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

조회 수: 6 (최근 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?
Torsten
Torsten 2024년 1월 13일
편집: Torsten 2024년 1월 13일
Not in 3d where spheres intersect. And this is reflected by having two equations for three unknowns.

댓글을 달려면 로그인하십시오.


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