Main Content

translate

Translate geometry

Since R2020a

Description

example

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

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)

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

Mesh the geometry and plot the mesh.

generateMesh(model);

figure
pdemesh(model)

Figure contains an axes object. The axes object contains 2 objects of type line.

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)

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

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)

Figure contains an axes object. The axes object contains 3 objects of type line.

After modifying the geometry, always regenerate the mesh.

generateMesh(model);

figure
pdegplot(g)
hold on
pdemesh(model)

Figure contains an axes object. The axes object contains 3 objects of type line.

Input Arguments

collapse all

Geometry, specified as an fegeometry object, a DiscreteGeometry object, or an AnalyticGeometry 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

Resulting geometry, returned as an fegeometry object or a handle.

  • If the original geometry g is an fegeometry object, then h is a new fegeometry object representing the modified geometry. The original geometry g remains unchanged.

  • If the original geometry g is a DiscreteGeometry object, then h is a handle to the modified DiscreteGeometry object g.

  • If g is an AnalyticGeometry object, then h is a handle to a new DiscreteGeometry object. The original geometry g remains unchanged.

Tips

  • After modifying a geometry, regenerate the mesh to ensure a proper mesh association with the new geometry.

  • If g is an fegeometry or AnalyticGeometry object, and you want to replace it with the modified geometry, assign the output to the original geometry, for example, g = translate(g,[1 2]).

Version History

Introduced in R2020a

expand all