# How many distances do you need to know if my point belongs to the cube?

I'm doing a project at the college subject de IoT, and I got lost in the math part. I have antennas that I will place in strategic places, and I have an RFID tag that transmits the signal to me, and with that I can know the distance from my tag to my antenna.

But I have several cubes inside that space where my antennas are. And I need to know if my tag is inside which cube. The cubes are projected from the floor to the ceiling of my space. So I guess I don't need to know how high my tag is from the ground, I just need to know if it's within the area of that cube.

My biggest difficulty is that my distances are from the label to a point in space (x, y, z), and then I imagine that I have to do some projection calculation, at (x, z) what my floor would be, and then know if that percentage point that area.

Can someone help me by telling me how many antennas (distance) I need, to know the coordinates (x, z) of my tag?

Knowing this I can do if this point (x, z) belongs to the projection of my cube on the floor. But if someone has a complete and even simpler way, I accept all help.

Thanks in advance, I've been struggling with this for a week, the project is all done, but I can't do this part of the math.

• If you will use 1 distance, you can determine possible tag location as sphere. If you will use 2 distances you can determine tag location as intersection of two spheres which is circle. If you will use 3 distances you can determine tag location as intersection of sphere and circle which is set of two points. If you use 4 distances you can determine tag location as unique. If you need only floor projection, then 3 distances from points having the same height will be enough. Aug 5 at 14:28
• Could you please answer the calculation with 3 distances with projection on the floor? Aug 5 at 15:23

Let we have three antennas having the same height from floor. Vertical axis is $$z$$. Let $$z$$ is measured from antennas level, so antennas have $$z=0$$. Tag location is $$(x,y,z)$$, floor projection which we need to find is $$(x,y)$$, antennas locations are $$(x_i,y_i,0)$$, $$i=1,2,3$$, distances from tag to antennas are $$d_i$$. Then $$(x_i-x)^2+(y_i-y)^2+z^2=d_i^2$$ $$(x^2+y^2+z^2)+(x_i^2+y_i^2-d_i^2)=2xx_i+2yy_i$$ Let subtract equations for $$i=1$$ and $$i=2$$: $$(x_1^2+y_1^2-d_1^2)-(x_2^2+y_2^2-d_2^2)=2x(x_1-x_2)+2y(y_1-y_2)$$ Let subtract equations for $$i=1$$ and $$i=3$$: $$(x_1^2+y_1^2-d_1^2)-(x_3^2+y_3^2-d_3^2)=2x(x_1-x_3)+2y(y_1-y_3)$$ This is linear system for $$x$$ and $$y$$, which has unique solution if antennas do not lie in the same straight line. Let write system in short: $$a_1x+a_2y=a_3, b_1x+b_2y=b_3$$ Then solution is $$x=-{{a_{3}\,b_{2}-a_{2}\,b_{3}}\over{a_{2}\,b_{1}-a_{1}\,b_{2}}},y={{a_{3}\,b_{1}-a_{1}\,b_{3}}\over{a_{2}\,b_{1}-a_{1}\,b_{2}}}$$ where $$a_1=2(x_1-x_2)$$, $$a_2=2(y_1-y_2)$$, $$a_3=(x_1^2+y_1^2-d_1^2)-(x_2^2+y_2^2-d_2^2)$$, $$b_1=2(x_1-x_3)$$, $$b_2=2(y_1-y_3)$$, $$b_3=(x_1^2+y_1^2-d_1^2)-(x_3^2+y_3^2-d_3^2)$$.
• Yes, we need to know $(x,y)$ of antennas too. Aug 8 at 6:44