Search code examples
c#unity-game-enginegeometrytransformpoint-clouds

Point Cloud Registration With Known Correspondence in Unity with C#


So I have a known set of points on a scanned 3D model of a physical object (let's say cube) named p1(x,y,z), p2(x,y,z) and p3(x,y,z).

The previously mention physical object is in front of the user and the user is going to tap the same 3 point on the physical cube (in quest 3 passthrough) that correspond to p1, p2, p3 that are p1', p2' and p3'. Though, p1', p2' and p3' may not be a perfect square as the user is only a human. How can I move the scanned 3D model to the location of the physical model that the user inputed?

Here's an image of the problem

Of course I looked at point cloud registration techniques like Umeyama's method but this seem very complex to implement in C# for my personally, though there is a python implementationhere. With this solution, I wouldn't actually know how to perform the translation with the resulting matrix... Looking for a slightly easier solution I found another post that does it with 2 points. This got me thinking that maybe I can use the same algorithm for two points, p1 and p2, to match it with p1' and p2' then rotate the model iteratively about p1' -> p2' until the p3 and p3' are at the somewhat exact position.


Solution

  • Have a look at the Kabsch solver for Unity in Jonathan Selstad's MathUtilities. He also wrote a blog post about it.

    Note that the sample continuously calls the solver in Update. If you only solve once, you can edit the extractRotation method to use more iterations.