主要内容

scale

R2026b

Scale mesh or scene object

Since R2026b

Description

Add-On Required: This feature requires the 3D Asset Processing Library for MATLAB add-on.

scale(meshORsceneObj,scaleFactor) scales the mesh or scene object meshORsceneObj by the specified scale factor scaleFactor.

example

Examples

collapse all

Define a simple pyramid with 5 vertices and 6 triangular faces.

vertices = [0 0 0; 1 0 0; 1 1 0; 0 1 0; 0.5 0.5 1];
faces = [1 2 5; 2 3 5; 3 4 5; 4 1 5; 1 3 4; 1 2 3];

Create a mesh with per-face color.

faceColors = uint8([230 50  50;    % red - front
                    50  180 50;    % green - right
                    50  100 230;   % blue - back
                    230 180 25;    % yellow - left
                    150 75  200;   % purple - bottom 1
                    25  200 200]); % cyan - bottom 2
pyramidMesh = asset3d.Mesh(vertices,faces,FaceColors=faceColors);

Scale mesh uniformly by a factor of 1.5.

scaledMesh = copy(pyramidMesh);
scale(scaledMesh,1.5)

Visualize the mesh scaled uniformly by 1.5 times compared to the original size.

figure
subplot(1,2,1)
patch(pyramidMesh,EdgeColor="k")
axis equal
title("Scale: 1.0")
subplot(1,2,2)
patch(scaledMesh,EdgeColor="k")
axis equal
title("Scale: 1.5")

Input Arguments

collapse all

Source mesh or scene, specified as a Mesh object or Scene object.

Scale factor, specified as a positive scalar or a three-element row vector of the form [sx sy sz]. Specify a scalar for uniform scaling across all axes. For non-uniform scaling, specify a three-element row vector. Values must be positive and finite.

Data Types: double

Version History

Introduced in R2026b