siavashk / pycpd

Pure Numpy Implementation of the Coherent Point Drift Algorithm
MIT License
518 stars 116 forks source link

[FEATURE] lock degrees of freedom #91

Open rejuce opened 3 days ago

rejuce commented 3 days ago

It's already possible to lock the scale. For my 3D Rigid Problem I know already that scale is 1, and rotation happens only around z axis. So I want to lock rotations around x, y. Is this possible? Or can you point me at which part of the code I have to look at to make that modification?

rejuce commented 3 days ago

do you think it is enough to modify the resulting new rotation matrix and zero the corresponding componentens in after line 80 in rigid_registration.py?

gattia commented 3 days ago

To be honest, Im not positive. I think that seems like a reasonable idea. Though, its inclear to me if its optimal to just set these to zero. So, you're thinking you would just retain the elements in Rz from attached that are used for the rotation matrix (eg the top left 2x2) and then set the others to 0/1 accordingly?

This could work.

If you give it a try and it does work out, a pull request to merge it to the main repository would be greatly appreciated.

Screenshot 2024-09-24 at 11 25 20 AM
rejuce commented 1 day ago

after the lin algebra magic at the lines before the resolting R is probably something like that grafik filtering one direction by 0 / 1 the corresponding components works because thats whats applied in the next iteration of the point cloud

restrictions are that i see: A) only one direction can be filterd/allowed and 2 must be locked. it is not possible to allow 2 direction because of overlapping elemtns in R B) the way the pcl converges might be altered, as from the in alg before rotation in all directions are assumen

nevertheless if it converges (even slower or faster) the final result of R should be correct for the direction.

I will add an artitional FilterDirection paramert and send you a PR