This tool transforms an existing vector or tensor variable into another reference frame which is specified by the user. Another way to describe it is that the tool rotates the variable. This was requested by a customer because they were interested in the components of vectors and tensors in arbitrary reference frames.

Note that the tool (as-is) does not rotate the variable along with the reference frame (the way EnSight frame mode will rotate objects attached to the frame). The variable is left unchanged, but it’s components are transformed to be in the basis of the new reference frame. For a vector, this is equivalent to taking the dot product of the vector with each of the 3 axes of the new coordinate system. This is also equivalent to rotating the vector in the opposite direction, which is how the vector will look if you visualize it in EnSight. If you would like the tool to rotate the vector WITH the reference frame then you can simply add “.transpose()” to the end of line 216, which transposes the rotation matrix and reverses the direction of rotation.

The new reference frame is determined using 3 points which are specified by the user. Point 1 is the origin of the new frame (the absolute location of this origin is irrelevant as no translations are performed). Point 2 is in the direction of X’, meaning the X’ axis is in the direction of a line from point 1 to point 2. Point 3 is the direction of Y’ (normal to the X’ axis). The image below shows a 2D representation. Points 1 and 2 determine the X’ axis, and point 3 determines the X’-Y’ plane, but Y’ does not necessarily pass through point 3.

These three points can be specified in two ways:

- If 3 or more query probes exist, the first 3 probes will be taken as the 3 points.
- If 2 or fewer probes exist, then a window will appear for the user to specify the XYZ locations of all 3 points.

The next step is to choose a variable to transform, and which parts to calculate the new variables on. All existing vectors and tensors will appear in the list of variables to select.

The script then runs. The user should see these results:

- A new axis triad will be displayed (centered at (0,0,0)). The triad consists of three “3D arrow” annotations and they can be edited if desired.
- Intermediate scalar variables will be created and placed in the group “p_scalars”. 3 scalars will be created for vectors, 18 for tensors. The scalars are needed for the calculation, and removing them (deactivating them) will also remove the final variable.
- A new vector or tensor will be created with “_p” tagged to the end of the variable name. “p” here stands for “prime” meaning the primed coordinate system. When this variable is created the script is finished (there is no pop-up window indicating the script has completed running).

This tool was designed to meet the specifications of a single customer. Many aspects of how the script operates could be easily changed to make it more suitable for other users. For example, there could be a different way to define the rotation, or the tool could be made to rotate more than one variable at a time.

Limitations and warnings

- By running the tool repeatedly, any number of vectors can be transformed but rotating a tensor will deactivate the previous tensor.
- The accuracy of the transformation has not been extensively tested. If errors exist in the calculation they could occur for vectors only, or tensors only, or for both types.
- EnSight 10 only. It could be adapted to EnSight 9 with little effort, if requested.

Download the tool and icon: (updated 2012-09-18)

transform_variable.zip