Similar to **transformPoints** for the mesh, **surfaceTransformPoints** can translate, rotate and scale a surface mesh. This is particularly helpful, when the geometry in question is located in an undesirable position in space and must be moved accordingly.

#!/bin/bash export FILE="geometry.stl" surfaceTransformPoints -translate "(1 1 1)" $FILE surfaceTransformPoints -scale "(10 10 10)" $FILE

The above illustrate the most basic functionalities of **surfaceTransformPoints**: translating and scaling. Rotating is a little bit more complex, as a variety of different methods and conventions exist. For the rotations, **surfaceTransformPoints** offers three different methods of defining the actual rotation. For sake of this example, we will be rotating the gray polygon by 90 degrees around the y axis, using all three methods.

### Rotate between two vectors

It is important to pass the rotating vectors as shown in the above figure. The quotation marks are used to pass the arguments as one single string token to the executable. Otherwise the shell would parse the brackets as part of a shell expression, which in turn leads to undesired behaviour. OpenFOAM parses this string as a `Pair<vector>`

, which by definition has a length of 2. Both vectors are normalized and a rotation tensor is generated from these two vectors. All points on the surface are then transformed with this tensor, leaving the connectivity untouched.

### Roll-Pitch-Yaw

When the roll-pitch-yaw convention is selected for the rotation, three consecutive rotations are performed using quaternions. The three angles are passed in degrees (not radians!) as a vector to **surfaceTransformPoints**.

#!/bin/bash export FILE="geometry.stl" surfaceTransformPoints -rollPitchYaw "(0 90 0)" $FILE

Similar to the basic rotation presented above, the quotation marks have to be put around the vector. Internally, a `quaternion`

is constructed from these three angles, which in turn is handled as a multiplication of three individual quaternions: first around the x-axis, then around the y-axis and finally around the z-axis, as shown in the snippet of the `quaternion`

constructor below:

inline Foam::quaternion::quaternion ( const scalar angleX, const scalar angleY, const scalar angleZ ) { operator=(quaternion(vector(1, 0, 0), angleX)); operator*=(quaternion(vector(0, 1, 0), angleY)); operator*=(quaternion(vector(0, 0, 1), angleZ)); }

### Yaw-Pitch-Roll

The yaw-pitch-roll convention works in a similar fashion as the roll-pitch-yaw convention does. The only major difference is that the rotations do not start with the rotation around the x-axis (roll), but with the rotation around the z-axis (yaw).

#!/bin/bash export FILE="geometry.stl" surfaceTransformPoints -yawPitchRoll "(0 90 0)" $FILE

## 3 Comments. Leave new

Thank you Jens!

Creat article, was just looking for the tips how to modify my stl and…. here it is!

Kind regards,

Alexander

Hi Alexander,

I’m glad that this article is of help for you. This tool is really handy, as you don’t have to move the geometry with paraview anymore, which can be a bit of a pain.

Jens

Jens,

thank you very much for the article, it is a great help to understanding the workings of openfoam.

Would you know if surfaceTransformPoints can be used to rotate a geometry about a user define coordinate system (eg rotate by (0 90 0) about coordinate system (100 0 10)). I would like to rotate a ship about the LCF and not about the origin as it happens at the moment.

With kind regards,

Constantinos