Search code examples
mathhashtransformuniqueidentifieridentifier

How to store information of two 3D point clouds using only one point cloud?


Say I have two 3D point clouds which represents the start and end point of a transformation. Now I want to store both the start and end point cloud information into a database, but the database only allows entry of one point cloud. Is there any way to store the 3D coordinates of one "representative" point cloud as an identifier so that one can always reproduce the start and end point clouds from that identifier (using e.g. some fixed rule of mathematical transformation or hashing)?


Solution

  • We likely need more specific details of the restrictions imposed by the database and possibly the nature of the points themselves (positive/negative, integer/rational/real, etc.) to provide a concrete answer. However, I'll at least provide a few suggestions below.

    Is the database strictly limited to 3 dimensions? If it can support 6+ dimensional data, just encode the second point in the extra axes and you're done. If it can at least support 4 dimensions, you can use the 4th dimension as a unique identifier for each point, merge to two point clouds, and pair up the start/end points by that 4th dimension.

    Are the points integer coordinates? If so, you can use the Cantor Pairing Function to map x1 and x2 to a single unique integer, x3, and do the same for the y and z coordinates for each point. If they are not integers, but precision is not a huge concern, you could scale up your coordinates by some large factor and then round to nearest integer, then apply the pairing trick.

    If precision allows, you could also combine these two tactics. Say your points span [-1e3, 1e3] on the x-axis, and you don't need a lot of precision. You could add k * 1e4 to the k'th start/end point's x component. If you sort your points by their new x component, it'll pair up the start and end points. You can do something similar with the y or z components to distinguish whether its the start or the end. You can of course recover the original points by taking each component modulo your multiple.