主要内容

sphereModel

R2026b

Object for storing a parametric sphere model

Description

The sphereModel object stores the parameters of a parametric sphere model. After you create a sphereModel object, you can extract sphere surface points and points within the sphere using object functions. Sphere models are used to store the output of the pcfitsphere function, which fits a sphere over a point cloud.

Creation

There are two ways to create a sphereModel object.

  • Create a sphere model by specifying the sphere parameters in the sphereModel object.

  • Fit a sphere model over a point cloud using the pcfitsphere function.

Description

model = sphereModel(parameters) constructs a parametric sphere model from the specified parameters. The parameters argument is a 1-by-4 numeric vector that determines the value of the Parameters property.

example

Input Arguments

expand all

Sphere parameters, specified as a 1-by-4 vector. This input specifies the Parameters property. The four parameters [a b c d] satisfy this equation for a sphere:

(x−a)2+(y−b)2+(z−c)2=d2

Where, [a b c d] are defined as:

  • [a b c] specifies the center of the sphere, in the form [x y z], and corresponds to the Center property.

  • d specifies the radius of the sphere and corresponds to the Radius property.

Properties

expand all

This property is read-only.

Sphere model parameters, stored as a 1-by-4 numeric vector. This property is set by the parameters input.

This property is read-only.

Center of the sphere, stored as a 1-by-3 vector of form [xc yc zc]. The elements xc,yc,zc specify the x-, y-, and z-coordinates of the center coordinates of the sphere, respectively.

This property is read-only.

Radius of the sphere, stored as a scalar value.

Object Functions

plotPlot parametric model
findPointsInModelFind points in or on surface of geometric model
transformTransform geometric models between coordinate frames

Examples

collapse all

Load a point cloud into the workspace.

load("object3d.mat");

Display the point cloud and label the figure.

figure
pcshow(ptCloud)
title("Detect a sphere in a point cloud")

Figure contains an axes object. The axes object with title Detect a sphere in a point cloud contains an object of type scatter.

Set the maximum point-to-sphere distance for sphere fitting to 1cm.

maxDistance = 0.01;

Set the region of interest to constrain the search.

roi = [-inf,0.5;0.2,0.4;0.1,inf];
sampleIndices = findPointsInROI(ptCloud,roi);

Detect the globe in the point cloud and extract it.

[model,inlierIndices] = pcfitsphere(ptCloud,maxDistance,SampleIndices=sampleIndices);
globe = select(ptCloud,inlierIndices);

Plot the extracted globe.

figure
pcshow(globe)
title("Globe Point Cloud")

Figure contains an axes object. The axes object with title Globe Point Cloud contains an object of type scatter.

Version History

Introduced in R2015b

expand all