Main Content

normalRotation

Compute transform for rotation of normal to plane

Since R2020b

Description

example

tform = normalRotation(model,referenceVector) returns the geometric transformation object for a normal vector of a plane to the reference vector, referenceVector. model is a planeModel.

Examples

collapse all

Construct a velodyneFileReader object.

veloReader = velodyneFileReader('lidarData_ConstructionRoad.pcap','HDL32E');

Read the first frame of lidar data.

frameNumber = 1;
ptCloud  = readFrame(veloReader,frameNumber);

Find the ground plane.

maxDistance = 0.4;
referenceVector = [0 0 1];

groundPlane = pcfitplane(ptCloud,maxDistance,referenceVector);

Transform the ground plane such that it is parallel to the X-Y plane.

tform = normalRotation(groundPlane,referenceVector);

Transform the point cloud.

ptCloudOut = pctransform(ptCloud,tform);

Display the original and transformed point cloud.

planeParams = groundPlane.Parameters * tform.T;
transformedPlane = planeModel(planeParams);
figure;
pcshowpair(ptCloudOut,ptCloud);
hold on;
plot(groundPlane, 'Color', 'magenta');
plot(transformedPlane, 'Color', 'green');

Input Arguments

collapse all

Parametric plane model returned by planeModel.

Reference vector, specified as a 1-by-3 vector.

Output Arguments

collapse all

Geometric transformation, returned as a rigidtform3d object. The rigidtform3d object describes the rigid 3-D transformation that aligns the normal vector of a plane to referenceVector.

Version History

Introduced in R2020b

expand all