# translate

Translate surface mesh

Since R2022b

## Syntax

``translate(mesh,translationVector)``
``translate(mesh,translationVector,pivot)``

## Description

example

````translate(mesh,translationVector)` translates the surface mesh, with respect to the world origin, by the values specified in `translationVector` along the x-, y-, z- axes.```
````translate(mesh,translationVector,pivot)` translates the mesh with respect to the specified pivot point. ```

## Examples

collapse all

Define mesh vertices for a surface mesh.

```vertices = [3 1 3; 3 3 3; 1 3 3; 1 1 3; ... 3 1 1; 3 3 1; 1 3 1; 1 1 1];```

Define the mesh faces using the vertices.

```faces = [6 2 1; 1 5 6; 8 4 3; 3 7 8; 6 7 3; 3 2 6; ... 5 1 4; 4 8 5; 4 1 2; 2 3 4; 7 6 5; 5 8 7];```

Create the surface mesh.

`mesh = surfaceMesh(vertices,faces);`

Define the translation vector, using the mesh center as the pivot point for translation.

```translationVec = [1 2 3]; pivot = vertexCenter(mesh);```

Translate the surface mesh with respect to its center.

`translate(mesh,translationVec,pivot)`

Display the translated mesh vertices.

` mesh.Vertices`
```ans = 8×3 2 1 4 2 3 4 0 3 4 0 1 4 2 1 2 2 3 2 0 3 2 0 1 2 ```

## Input Arguments

collapse all

Surface mesh, specified as a `surfaceMesh` object.

Translation along x-, y-, z-axes, specified as a three-element vector of the form [ x y z]. If you do not specify a pivot point, this translation is with respect to the world origin.

Pivot point coordinates, specified as a three-element vector of the form [ x y z]. The function translates the mesh with respect to this point.

## Version History

Introduced in R2022b