MATLAB: Pcregistercpd – use tform manually

pcregistercpdtform

Hello,
I have a problem understanding how the tform (transformation matrix) from the function pcregistercpd works.
First of all, what I have and have done:
I have two point clouds, let's call them reference_pc and query_pc.
I use pcregistercpd to make an affine transformation to align reference_pc and query_pc. It works very nicely.
Now comes my problem:
I'd like to manually use the transformation matrix tform and align query_pc to reference_pc.
What is tform? This is the documentation for it. It's a 4×4 matrix, where (I'm assuming) the first rows are the rotation components and the fourth row is the translation component. So, for me to use it manually I'll have to make a matrix multiplication. Like this:
aligned_query_pc = reference_pc * tform
The problem with thtis is that my point clouds are just nx3 matrices. So I just put a zero column on the back of both point clouds' matrices.
This doesn't work. When I plot the point clouds, they are not aligned.
Can you help me understand this?
I have uploaded a workspace, in case you want to try it out.
You can use these lines to plot them:
figure
axis equal
scatter3(AAA_reference(:,1),AAA_reference(:,2),AAA_reference(:,3),10,'MarkerEdgeColor','k', 'MarkerFaceColor','g')
hold on
scatter3(AAA_query_zeros(:,1),AAA_query_zeros(:,2),AAA_query_zeros(:,3),10,'MarkerEdgeColor','k', 'MarkerFaceColor','m')
hold on
scatter3(aligned_query_pc(:,1),aligned_query_pc(:,2),aligned_query_pc(:,3),10,'MarkerEdgeColor','k', 'MarkerFaceColor','b')

Best Answer

Well, my bad. It seems that it doesn't make sense to append the matrices with zeroes but with ones. I swear I tried it, but it did not work. I've tried it again showing it to a coworker and... it worked.