Plotting XYZ coordinates, given an array of distances to n 3D vertices.

3dcoordinate systemsgraphing-functionstrigonometry

I believe this is more of a mathematical topic than a gaming one, hence the post here.

For the sake of context: In a game called Subnautica, the player has the ability to move about in an underwater area. They can position an unlimited number of beacons either on the surface or underwater. Beacons do not move once placed. The player is always able to see their current depth (inverse of the Y axis; Y = 0 is at the water's surface), and the current distance (in metres) to each beacon. So the player can travel to any point in the world, and then record their distance to each of the beacons 1, 2 .. n.

Scenario 1: The player places three beacons in a non-degenerate triangle at the water's surface (Y=0), and also limits their own movement to Y=0. Let's say we arbitrarily define a coordinate system with Beacon 1 at [X=0, Y=0, Z=0] and Beacon 2 at [X=0, Y=0, Z=100]. We observe that Beacon 3 is 120 metres away from the first and 50 metres away from the second. We can also tell by looking that Beacon 3 has a negative X coordinate. Is this enough information to work out XZ coordinates for beacon 3? Is there an iterative or even better, an analytical formula to do this?

Scenario 2: The beacons remain in the same positions as before, but the player now moves to different locations underwater. If they swim 100m away from Beacon 1 along X and 100m vertically down (Y = -100), the displayed distance from that beacon is about 140m. Is it possible to work out the player's XZ coordinates for any point underwater, given only the distances to beacons and their depth (-Y)? If not, what if we add one or more extra beacons (extra ones are also limited to the surface)?

Scenario 3: The player now has the freedom of placing any number of beacons anywhere on the surface or underwater. Does this help with plotting XYZ coordinates?

Best Answer

You can try drawing a circle around both beacons with radius of the distance from the 3rd one. you can see that you will get 2 answers as there are 2 points of intersection between the circles. Therefore you will end up with ± somewhere giving you 2 possible answers. If you have more information, for example if x is positive or negative you can eliminate this.

Same goes with 3D. you draw a sphere around each beacon and end up with a circle where the 3rd beacon can be and you can solve where it actually is if you have more information about its position.

Continuing, same will be true for higher dimensions. You will have an $n+1-a$ (where a is amout of points we can measure distance from and n is the amout of coordinates in the system) dimensional sphere of possible locations. So, yes the ability of player to move around will help solve where the 3rd beacon is. In most cases ability to change 1 of player's coordinates will be enough, but in some you might need more. To solve where the player is, you will need 4 beacons as $3+1-4 = 0$ limiting the sphere of possibilities to a 0 dimensional one which is a point. A 1 dimensional one in 2 points.

As for solving, you can do it algebraically. Lets solve the problem for the 2 dimensional case: $$ a = [0,0]\ b = [0,100]\ c=[x,y] $$ $$ ((x-0)^2+(y-0)^2)^{1/2} = 130 $$ $$ ((x-0)^2+(y-100)^2)^{1/2} = 50 $$ we raise both to second power $$ x^2+ y^2-200y+10000 = 50^2 = 2500 $$ $$ x^2+y^2 = 130^2 = 16900 $$ now try to solve for x and y $$ x^2+ y^2-200y+10000 $$ $$ - $$ $$ x^2+y^2 $$ $$ = $$ $$ -200y+10000 = 2500 - 16900 = -14400 $$ $$ -200y = -24400 \ 200y = 24400\ y = 122 $$ now solve x $$ x^2 + y^2 = 16900 $$ substract $y^2$ $$ x^2 + 14884 = 16900 $$ $$ x^2 = 2016 $$ we add a plusminus becasue we dont know if x is positive or negative $$ x = ±\sqrt{x^2} $$ $$ x \approx ±44.89 $$ in your scenario we know x is negative, therefore $c\approx[-44.89,122]$

Related Question