translate

Translate geometry

Description

example

translate(g,s) translates the geometry g by the distance s.

h = translate(g,s) returns a handle h to the modified geometry object g.

Examples

collapse all

Translate a geometry by different distances along the x- and y-axes.

Create a model.

model = createpde;

Import and plot a geometry.

g = importGeometry(model,'PlateHolePlanar.stl');
pdegplot(g)

Mesh the geometry and plot the mesh.

generateMesh(model);

figure
pdemesh(model)

Translate the 2-D geometry by 1 along the x-axis and by 2 along the y-axis. Plot the result.

translate(g,[1 2]);
pdegplot(g)

Plot the geometry and mesh. The translate function modifies a geometry, but it does not modify a mesh.

figure
pdegplot(g)
hold on
pdemesh(model)

After modifying the geometry, always regenerate the mesh.

generateMesh(model);

figure
pdegplot(g)
hold on
pdemesh(model)

Input Arguments

collapse all

Geometry, specified as a DiscreteGeometry object.

Translation distance, specified as a vector of two or three real numbers. The distance is a vector of two elements for a 2-D geometry or three elements for a 3-D geometry. The elements specify the distance along the x-, y-, and, for a 3-D geometry, z-axes.

Output Arguments

collapse all

Modified geometry, returned as a handle to the modified geometry object g.

Limitations

Tips

  • translate modifies a geometry, but it does not modify a mesh. After modifying a geometry, regenerate the mesh to ensure a proper mesh association with the new geometry.

Introduced in R2020a