Let global axis direction vectors be denoted by X,Y,Z, and let local axis direction vectors be denoted x,y,z. The algorithm for determining local axis of an element is as follows:
Given two nodes (starting node i, and end node j):
\[\bar{v_i}=\{x_i,y_i,z_i\}, \: \bar{v_j}=\{x_i,y_i,z_i\}\]+x local axis:
\[\lambda_x' = \bar{v_j} - \bar{v_i}\] \[\lambda_x = \frac{\lambda_x'}{ ||\lambda_x'|| }\]+z local axis:
\[\lambda_z' = \left\{ \begin{array}\\ \{0,0,1\} & \mbox{if } \ \lambda_x = \{0,1,0\} \\ \{0,0,-1\} & \mbox{if } \ \lambda_x = \{0,-1,0\} \\ \lambda_x \times \{0,1,0\} & \mbox{otherwise } \end{array} \right.\] \[\lambda_z = \frac{\lambda_z'}{ ||\lambda_z'|| }\]We are effectively enforcing the +y axis to always point skyward (up).
+y local axis:
\[\lambda_y' = \lambda_z \times \lambda_x\] \[\lambda_y = \frac{\lambda_y'}{ ||\lambda_y'|| }\]The elements of the lambda vectors are direction cosines of your local axis (\(\alpha, \beta, \gamma\)). The 3x3 transformation matrix is defined as:
\[\gamma_p = \begin{bmatrix} \lambda_x \\ \lambda_y \\ \lambda_z \end{bmatrix}\\= \begin{bmatrix} \alpha_x & \beta_x & \gamma_x \\ \alpha_y & \beta_y & \gamma_y \\ \alpha_z & \beta_z & \gamma_z \\ \end{bmatrix}\\\]Rotate web-direction vector (+y) by angle beta:
\[\gamma_b = \begin{bmatrix} 1 & 0 & 0\\ 0 & cos(\beta) & sin(\beta)\\ 0 & sin(\beta) & cos(\beta) \end{bmatrix}\\\]Matrix multiply the above gamma matrices:
\[\gamma = \gamma_b \gamma_p\]Finally, our element transformation matrix T can be defined as a 12x12 matrix with gamma on the diagonal. Let
\[O_{3x3} = \begin{bmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix}\\\] \[T = \begin{bmatrix} \gamma & O_{3x3} & O_{3x3} & O_{3x3}\\ O_{3x3} & \gamma & O_{3x3} & O_{3x3}\\ O_{3x3} & O_{3x3} & \gamma & O_{3x3}\\ O_{3x3} & O_{3x3} & O_{3x3} & \gamma \end{bmatrix}\\\]Note that all direction vectors must be normalized to be unit vectors. Here is an example implementation that I wrote while developing MSApy.
To verify, let do an example from the MASTAN textbook. Example 5.5. Using the code above, we get the same answer! Figure 6: Verification Problem
Note that the solution presented in the textbook is an alternative approach that uses the Euler angles to apply 3 sets of rotational transformation one after each other about the y, z’, and x’ axis (like a gimbal). Nevertheless the same answer is obtained.
In FEM modeling, you may have been told to follow certain conventions when drawing elements (e.g. draw nodes counter clockwise, left to right, bottom to top, and etc.). There are good reasons for this, one of them is directly relevant to our discussion of local-axes.
First of all, not following convention won’t invalidate the analysis necessarily. Element nodal forces and displacements should still be correct because stiffnesses at each degree of freedom are mapped correctly regardless of member orientation.
However, problems arise when you use any force plotting features such as for moment diagram, Von Mises stress, and etc. To illustrate, let’s say we have the following structure with directly opposing local axes.
Figure 7: Why Follow Conventions When FEM Modeling
The fact that we enforce upward-facing web direction vector (+y) create situations where +z local axes are flipped and discontinuous if conventions are not followed. Let’s see this in action. Modeling the structure above in RISA-3D:
Figure 8: Line Element With Inconsistent Local Axes
Figure 9: Shell Element with Inconsistent Local Axes