Reputation: 529
I have a set of e.g. 8 points. I know all distances between each points. Is there an algorithm to reconstruct the 3d coordinates of those points.
Upvotes: 4
Views: 328
Reputation: 5304
What you are try to do is called Trilateration. It might be wise to do a bit of research before you proceed, as it's tricky to get right. However, I'll start you off with the following.
The following should work, as long as you have the actual 3D distances. Problems may come up if you don't.
The first 3 steps are enough to orient and fix the coordinates.
Solving steps 3 and 4 can be done by making use of planar triangles, that form easily due to how the points are centered.
Upvotes: 5
Reputation: 5448
Let assume that points are in a general position. That no 3 points are on a same line, and no 4 points are on a same plane. It isn't a restriction, just to make algorithm simpler without checks for a special cases.
Intersection, if exists, of four spheres (in a general position) is a single point. It can be seen since intersection of two spheres is a circle, intersection of three spheres are 2 points, and if center of forth sphere isn't on a plane with centers of other 3 spheres, that sphere can pass only through one of intersection points.
So, if distances are valid, than shape can be created by incremental adding points to it.
Position on first 4 points defines orientation. E.g. first point set in origin, second point set on +X on given distance to first, third point set in XY plane in +Y direction on intersection of circles, and forth point set in +Z direction on intersection of 3 spheres.
Additional points can be positioned by intersection of 4 spheres with centers in first 4 points and radii given by distances to them.
Upvotes: 2