Linear Algebra. Points matching with SVD in 3D space

Linear Algebra.

Points matching with SVD in 3D spaceAndrey NikishaevBlockedUnblockFollowFollowingJun 30ProblemWe need to find best rotation & translation params between two sets of points in 3D space.

This type of transformation called Euclidean as it preserves sizes.

Our task to solve equation R*A + t = BSolutionThere are many ways of getting things done almost in any case, but currently we will use SVD for this.

You ask why? — Because matrix is basically linear transformation and SVD can decompose it on Rotation(U), Scaling(Σ), Rotation(V)RotationTo get rotation first we need to find out center of it.

So we will find centroids of two datasets.

centroid_p = mean([{xi,yi,xi} in X])First we will re-center our datasets and create covariance matrix H of two them, where Pa, Pb are points in datasets.

Now we use SVD to find out U and V matricesAnd out rotation matrix are equal R = V*U.

TProblem with SVDBecause solving SVD implies some sort of randomness(there can be different number of correct solutions) it sometimes make rotation matrix to be sign reflected.

We can fix this by checking determinant of R matrix and if it negative.

If so then multiply 3rd column of R by -1TranslationThis is very simple.

 1) recenter with -centroid_A2) Rotate and move to center of dataset BCodeExample of code you can check here on my google colabAlso you can checkout example on affine transformation.

. More details

Leave a Reply