Main Content


Auto-scale object mesh to match specified cuboid dimensions



scaledMesh = scaleToFit(mesh,dims) auto-scales the object mesh to match the dimensions of a cuboid specified in the structure dims.


collapse all

This example shows how to create an extendedObjectMesh object and auto-scale the object to the required dimensions.

Construct a sphere mesh of unit dimensions.

sph = extendedObjectMesh('sphere');

Auto-scale the mesh to the dimensions in dims.

dims = struct('Length',5,'Width',10,'Height',3,'OriginOffset',[0 0 -3]);
sph = scaleToFit(sph,dims);

Visualize the mesh.


Figure contains an axes. The axes contains an object of type patch.

Input Arguments

collapse all

Extended object mesh, specified as an extendedObjectMesh

Dimensions of the cuboid to scale an object mesh, specified as a struct with these fields:

  • Length – Length of the cuboid

  • Width – Width of the cuboid

  • Height – Height of the cuboid

  • OriginOffset – Origin offset in 3-D coordinates

All the dimensions are in meters.

Data Types: struct

Output Arguments

collapse all

Scaled object mesh, returned as an extendedObjectMesh object.

Introduced in R2020a