Visualize Deviation of Fit Plane from Reference Vector

4 views (last 30 days)
I am trying to replicate the process outlined in normalRotation to visualized deviation from the [0 1 0] plane instead of the [0 0 1] plane. I suspect the issue has to do with mishandling of the tform object for my use case.
% My code
maxDistance = 0.1;
referenceVector = [0 1 0];
target_pc = pointCloud(xyz_data);
targetPlane = pcfitplane(target_pc,maxDistance,referenceVector);
tform = normalRotation(targetPlane,referenceVector);
target_tform = pctransform(target_pc,tform);
planeParams = targetPlane.Parameters * tform.T;
transformedPlane = planeModel(planeParams);
figure;
pcshowpair(target_tform,target_pc);
title(sprintf('target site %i', iSite))
xlabel('x'); ylabel('y'); zlabel('z');
hold on;
plot(targetPlane, 'Color', 'magenta');
plot(transformedPlane, 'Color', 'green');

Answers (1)

Sugandhi
Sugandhi on 22 Aug 2023
Hi,
I understand that you are trying to visualize the deviation of a point cloud from a reference plane ([0 1 0] plane) instead of the [0 0 1] plane.
One of the possible workarounds could be:
  1. Instead of directly multiplying the target plane's parameters with the transformation matrix, you need to extract the rotation matrix from ‘tform.T’ and apply it to the plane parameters to represent the rotation component.
  2. The translation component of the transformation matrix doesn't affect the plane parameters, hence apply the rotation part to the plane parameters.
  3. The transformed plane's parameters need to include the translation component (fourth element) from the original target plane parameters.

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!