rotate

Rotate geometry

Since R2020a

Syntax

``h = rotate(g,theta)``
``h = rotate(g,theta,refpoint)``
``h = rotate(g,theta,refpoint1,refpoint2)``

Description

example

````h = rotate(g,theta)` rotates the geometry `g` about the z-axis by the angle `theta`, specified in degrees. Rotation follows the right-hand rule: a positive angle `theta` rotates counterclockwise, while sighting along the z-axis toward the origin.```
````h = rotate(g,theta,refpoint)` uses the rotation axis specified by the reference point `refpoint`. The axis of rotation is the line in the z-direction passing through the reference point.```

example

````h = rotate(g,theta,refpoint1,refpoint2)` uses the rotation axis specified by two reference points. This syntax is only valid for a 3-D geometry.```

Examples

collapse all

Rotate a geometry with and without specifying the reference point for the axis of rotation.

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)```

Rotate the geometry around the default z-axis by 45 degrees. Plot the result.

```rotate(g,45); figure pdegplot(g)```

Plot the geometry and mesh. The `rotate` 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)```

Restore the original geometry position.

`rotate(g,-45);`

Rotate the geometry by the same angle, but this time use the center of the geometry as a reference point. The axis of rotation is the line in the z-direction passing through the reference point.

`rotate(g,45,[5 10]);`

Regenerate the mesh.

`generateMesh(model);`

Plot the resulting geometry and mesh.

```figure subplot(1,2,1) pdegplot(model) axis([-6 16 -1 21]) subplot(1,2,2) pdemesh(model) axis([-6 16 -1 21])```

Rotate a geometry with and without specifying the reference points for the axis of rotation.

Create and plot a geometry.

```g = multicuboid(1,5,1); pdegplot(g)```

Rotate a 3-D geometry around the default z-axis by 45 degrees. Plot the result.

```rotate(g,45); pdegplot(g)```

Restore the original geometry position.

```rotate(g,-45); pdegplot(g)```

Rotate the geometry by the same angle, but this time around the y-axis.

```rotate(g,45,[0 0 0],[0 1 0]); pdegplot(g)```

Input Arguments

collapse all

Geometry, specified as an `fegeometry` object, a `DiscreteGeometry` object, or an `AnalyticGeometry` object.

Example: `g = model.Geometry`

Rotation angle in degrees, specified as a real number.

Example: `rotate(g,90)`

Reference point for a rotation axis, specified as a vector of two or three real numbers. The axis of rotation is the line in the z-direction passing through the reference point.

Example: `rotate(g,45,[1 1.5])`

Reference points that define a rotation axis for a 3-D geometry, specified as a vector of three real numbers.

Example: `rotate(g,45,[0 0 0],[1 1 1])`

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 = rotate(g,90)```.

Version History

Introduced in R2020a

expand all