2

Context

I'm making a 2D sci-fi game, and I've convinced myself that it would be neat to have player positions described in reference to nearby stars rather than using some kind of coordinate system. Realistically, the player would not have any way to measure its distance to nearby stars, but it could measure angles between nearby stars.

Problem

You would need to use at least 3 nearby stars to identify the Player's location, but just any old 3 stars are not sufficient. Under certain conditions, the 3 angles between the Player and each of the 3 stars can represent 2 points.

Visual showing 3 stars, the player position, and a degenerate point that has the same angles as the player

Here the red circles are the 3 stars, the pink circle is the Player, and the Yellow circle is a degenerate point. The arcs show all of the points (with some error margin) that can be represented by just a single angle (ie. The green arcs show all the possible positions that have the same angle Star 2 - Player - Star 3).

Keeping the same star positions, you can manipulate the player position to find an arangement that does not produce a degenerate point.

Visual showing 3 stars and the player position, with the player position modified so that there is no degenerate point

(Here is the janky jsfiddle I made that generates these images. Re-run to randomize the star positions, click to move the player position to the mouse position. This is not precise nor efficient, but serves to provide a visual aid)

Question

How could I compute whether or not a given relationship produces a degenerate point?

Or perhaps more relevant to my problem: Given a set of nearby stars, how could I select 3 stars such that the angles produced resolve to exactly 1 point in space?

Sunlis
  • 21
  • 3 stars should not be on straight line. – herb steinberg Jul 13 '22 at 22:29
  • 3 stars in a straight line will produce a degenerate point, yes. But the player has no means of identifying whether or not any 3 stars are in a straight line. Remember, the player only knows the angles to each star. You would also need distance to identify whether or not the stars make a straight line.

    A straight line is also clearly not the only degenerate case, as the example image I provided shows 3 stars not in a straight line that still produce a degenerate point.

    – Sunlis Jul 13 '22 at 22:38

2 Answers2

1

This isn't anywhere near a complete answer.

But this could be on the way to one.

I have tried to reproduce your diagrams in Desmos. (The diagrams are interactive.)

The construction appears to be:

  • Given three fixed points (the stars)
  • Given a point (the ship)
  • Two stars and the ship determine a circle containing those three points. The angle between the displacement vectors from the ship to the two stars is constant for all ship positions on the arc containing the ship. (The other arc [which completes the circle] does not contain the ship.)
  • Two stars and the ship determine another circle containing those two stars and a point that is the ship reflected across the line joining the two stars. (The reflected-ship is the magenta X.) The angle between the displacement vectors from the reflected-ship to the two stars is the same constant for all positions on the arc containing the reflected-ship.
  • The three circles associated with the reflected-ships have a common intersection, which could lead to a degenerate point.

https://www.desmos.com/calculator/htw1bniiod
The three dashed circles associated with the reflected-ships intersect in the arcs that contains the reflected-ships.
robphy-desmos-htw1bniiod

https://www.desmos.com/calculator/jxruewsve2
Here, the green dashed arc where the common intersection occurs does not contain the reflected-ship. (This might be a condition to test for.) Note that you can move the ship and obtain a degeneracy point like in the previous case. (Drag R to the lower right corner.) So, it's not just about the arrangement of the three stars.

robphy-desmos-jxruewsve2

Hope this helps.

robphy
  • 211
  • Wow Desmos is amazing! I've been building these diagrams myself with Javascript, but Desmos is way nicer – Sunlis Jul 14 '22 at 16:06
0

After doing more digging, I think the simplest way to guarantee uniqueness is to select 3 stars such that the Player is contained within the triangle formed by those 3 stars. Constructing a naive example we can see only 1 intersection of the 3 circles that circumscribe each of the pairs of stars and the player.

Checking this constraint in programmatically is pretty simple, as I just need to find the angles $S_1 R S_2$, $S_2 R S_3$, and $S_3 R S_1$. If the sum of angles is $360^o$, then our point is within that triange.

From there we ensure that we order the stars in a clockwise manner. This ordering makes it much more feasible to reconstruct the point from the encoded coordinates we generate. In my case, I decided to construct a coordinate in the form $S_A/A_{AB}/S_B/A_{BC}/S_C/A_{CA}$ where $S_i$ is the ID of the star, $A_{ij}$ is the angle $S_i R S_j$, and $A$, $B$, $C$ are the clockwise ordering of stars about the player.

Now to transform that coordinate back into a point in space. For each pair of stars, construct a perpendicular bisector (shown below in green).

triangle SA,SB,SC with perpendicular bisectors on each edge of the triangle

Now find a point on each bisector $T_{AB}$ such that the angle $S_A T_{AB} S_B$ is equal to $A_{AB}$ from our given coordinate. This is doable with some fairly basic trig.

visual showing a constructed point T_AB that has the same angle between S_A and S_B as R

With that new point we construct a circle (an arc would also do) that passes through $S_A$, $T_{AB}$, and $S_B$. See Get the equation of a circle when given 3 points on how to construct said circle.

Circle passing through S_A, T_AB, S_B, and R

Repeat for all 3 pairs and you now have something like this

Circles passing through each pair of stars, and the points T_XY constructed from their perpendicular bisector

Since we enforced that the player be within the triangle formed by the stars, we have also guaranteed that there will be exactly one point at which the 3 circles intersect. I followed the answers on Find intersecting point of three circles programmatically to build a method that takes those 3 circles and finds their intersect. With a properly tuned epsilon, we can now find our ship!

As a bonus here's a screen recording of the tool I built while I was working out this method:

GIF showing points S_A, S_B, S_C, and R being dragged around, and on-screen visuals telling us whether we can generate a coordinate for that arangement

Sunlis
  • 21