[Math] Solving polynomial equation system to find three dimensional location

polynomialssystems of equations

For an embedded systems project, I need to solve a system of equations. However, my algebraic skills are limited, and I am not able to solve it.

This question consists of the following parts.

  1. The math
  2. Tried methods
  3. Context

The system

The system is as follows.

$x^2 + y^2 + z^2 = r^2$

$i/i_1 = (x-x_1)^2 + (y-y_1)^2 + (z-z_1)^2$

$i/i_2 = (x-x_2)^2 + (y-y_2)^2 + (z-z_2)^2$

$i/i_3 = (x-x_3)^2 + (y-y_3)^2 + (z-z_3)^2$

I want to solve this for $i$, $x$, $y$, and $z$, so I get four formulas. The other variables, $r$, $i_1$, $i_2$, $i_3$, $x_1$, $x_2$, $x_3$, $y_1$, $y_2$, $y_3$, $z_1$, $z_2$, and $z_3$ are known when the formulas are needed, but are not constant.

Is this possible, and if so, how do I it?

Tried methods

First, I seperated x, from the second equation, and substituted the result in the other equations.

$x = \sqrt{i/i_1 – (y-y_1)^2 – (z-z_1)^2} + x_1$

As you see, this gets ugly very fast, so I think this is not the right way to do it.

Another method I tried was subtracting the equations from each other, but this did not lead to anything useful.

I gave everything to Wolframalpha, but it took too long, and required Wolframalpha pro to get more processing time, which I do not have.

My friends could not help me, or had no time, or are busy helping at the moment. Friends of friends did not very well. I guess facebook is not always the best option.

I searched Stackexchange using solve system of quadratic equations, and I found some questions. However, these did not give my enough insight to solve my own problem.

Context

The project I am working on, is about locating an object in three dimensional space. I do this by connecting three LDRs, which react to light, to an Arduino microcontroller. This controller is then connected to my computer, where I do the actual calculations, and simulate everything in a 3D scene. When I take my flashlight and shine light, I use the values from the LDRs, together with the assumption that the flashlight is at a fixed distance from the center of the LDRs, to approximate the location of the flashlight.

Best Answer

Yes, it is doable. Recall your first equation,

$$x^2+y^2+z^2 = r^2$$

More generally, define,

$$x_k^2+y_k^2+z_k^2 = s_k$$

Expand your first $i$ equation,

$$\begin{aligned} i/i_1\;&= (x-x_1)^2+(y-y_1)^2+(z-z_1)^2\\ &=\color{brown}{(x^2+y^2+z^2)}+\color{brown}{(x_1^2+y_1^2+z_1^2)}-2x_1 x-2y_1 y-2z_1 z\\ &=\color{brown}{r^2}+\color{brown}{s_1}-2x_1 x-2y_1 y-2z_1 z \end{aligned}$$

In short, expanding your three $i$ equations, you will get a system only linear in $x,y,z$,

$$i/i_1 = r^2+s_1-2x_1\,\color{blue}x-2y_1\,\color{blue}y-2z_1\,\color{blue}z\tag1$$

$$i/i_2 = r^2+s_2-2x_2\,\color{blue}x-2y_2\,\color{blue}y-2z_2\,\color{blue}z\tag2$$

$$i/i_3 = r^2+s_3-2x_3\,\color{blue}x-2y_3\,\color{blue}y-2z_3\,\color{blue}z\tag3$$

I'm sure you know how to solve for $x,y,z$ in those three. After doing so, substitute the expressions into,

$$x^2+y^2+z^2 = r^2\tag4$$

and you will end up with a quadratic in your last unknown $i$ expressed solely in the arbitrary values $r,\, i_k,\, x_k,\, y_k,\, z_k$.

Related Question