Finding coordinates of position given three coordinates and distances: 3D

758 Views Asked by At

I'm hoping to determine the x, y, z coordinates of a 4th position (D) given the coordinates of three other positions and their distances: $A(0.25, 0.25, 0.25), B(0.4663, 0, 0.25)$, and $C (0.3912, 0.1558, 0.3796)$.

$AD = 3.3285, BD = 3.3399, CD = 2.21$. Easiest to show with a picture, but I don't have enough rep. on the site to post a picture yet, so here's a Google Drive link:

enter image description here

Using the given angles, law of cosines, and distance formula gives me three nonlinear equations and three unknowns. Afraid I'm not seeing a way to either substitute or eliminate variables to solve for x, y, or z.

I tried this using Matlab's fsolve function. In editor:

function F = myfun(x)
F = [(0.25-x(1))^2+(0.25-x(2))^2+(0.25-x(3))^2-3.3285^2; (0.3912-x(1))^2+(0.1558-x(2))^2+(0.3796-x(3))^2-2.2124^2; (0.4663-x(1))^2+(x(2))^2+(0.25-x(3))^2-3.3399^2];

end

In the command window, initialize a guess for all 3 elements:

x0 = [0.25, 0.25, 0.25] (Just an arbitrary guess)

fsolve(@myfun, x0)

This returns the error: "fsolve stopped prematurely because it exceeded the function evaluation limit." Unsure how to proceed.

Thanks for any assistance!