translate
Shifts a polyshape by a given offset in x and y.
Category: Mathematics > Computational Geometry
Syntax
PG2 = translate(PG, v)
Moves every vertex of PG by the two-element vector v.
PG2 = translate(PG, x, y)
Moves the vertices by x along the x-axis and y along the y-axis.
Description
translate adds the offset to the coordinates of every boundary, holes included. Shape, area and orientation are unchanged, only the position moves. The input object is not modified; a new object is returned.
In this wiki the function is listed under computational geometry, and it acts on polyshape objects.
Input arguments
PG- A
polyshapeobject. v- Two-element vector
[dx dy]with the displacement. x, y- Scalar displacements along each axis (second form).
Output arguments
PG2- A new
polyshapewith the same shape, moved by the offset.
Example
Move a square
P = polyshape([0 1 1 0], [0 0 1 1]);
Q = translate(P, [2 3]);
disp(Q.Vertices)
Output
2 3
2 4
3 4
3 3