🌟Formulation for 3D Truss Element Transformation — With MATLAB Code
- Adisorn O.
- Apr 27
- 3 min read
by alpsdev, 2025

When working with 3D truss structures, the transformation between local and global coordinates becomes crucial. Fortunately, for truss elements, this transformation is much simpler than for frame elements, because:
✅ Only axial deformation along the member axis matters.✅ No bending, no torsion, no shear deformation.
This allows a very efficient shortcut for formulating the global stiffness matrix of a truss element.
1. 📚 Quick Theory
Given a 3D truss element:
Local axis x' is along the member.
Displacements only occur along x' direction.
The global displacements at each node are 3 DOFs:
U1,U2,U3U1, U2, U3 for node 1 (ux, uy, uz)
U4,U5,U6U4, U5, U6 for node 2 (ux, uy, uz)
🔵 Local Stiffness Matrix [k_local]
The basic 2×2 local stiffness matrix is:
[klocal]=EAL[1−1−11][k_{local}] = \frac{EA}{L} \begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}
where:
EE = Young’s modulus
AA = Cross-sectional area
LL = Member length
🔵 Transformation Matrix [T]
Since only x'-axis matters, we project the global displacements onto the local x' direction using a simple 2×6 matrix:
[T]=[lx ly lz 0 0 0 0 0 0 lx ly lz]
where:
lx,ly,lz = direction cosines of local x'-axis.
✅
First row maps displacements of node 1
Second row maps displacements of node 2
🔵 Global Stiffness Matrix [k_global]
The global 6×6 stiffness matrix is obtained by:
[kglobal]=T * [klocal]
✅ Very simple and very efficient!
🎨 3D Truss Shortcut Formulation
Here’s the visual concept:
Step 1: Define x'
Node 1 ---------------> Node 2
(x1,y1,z1) (x2,y2,z2)
|
|
local x'
Direction cosine:
l_x = (x2 - x1) / L
l_y = (y2 - y1) / L
l_z = (z2 - z1) / L
Step 2: Build T (2x6)
[T] =
[ l_x l_y l_z 0 0 0 ]
[ 0 0 0 l_x l_y l_z ]
Step 3: Local stiffness
[k_local] = (EA/L) * [1 -1; -1 1]
Step 4: Transform to global
[k_global] = T' * [k_local] * T
Result:
k_global is 6x6 matrix → ready for assembly!
2. 📜 MATLAB Code for 3D Truss Transformation
Here’s a compact MATLAB script to perform the full transformation:
% Node coordinates
x1 = 0; y1 = 0; z1 = 0;
x2 = 2; y2 = 2; z2 = 1;
% Material and section properties
E = 210e9; % Young's modulus (Pa)
A = 0.005; % Cross-section area (m^2)
% Step 1: Compute direction cosines
dx = x2 - x1;
dy = y2 - y1;
dz = z2 - z1;
L = sqrt(dx^2 + dy^2 + dz^2);
lx = dx/L;
ly = dy/L;
lz = dz/L;
% Step 2: Build T (2x6)
T = [lx ly lz 0 0 0;
0 0 0 lx ly lz];
% Step 3: Local stiffness matrix
k_local = (E*A/L) * [1 -1; -1 1];
% Step 4: Global stiffness matrix
k_global = T' * k_local * T;
% Display
disp('Local stiffness matrix [k_local]:')
disp(k_local)
disp('Transformation matrix [T]:')
disp(T)
disp('Global stiffness matrix [k_global]:')
disp(k_global)
✅ This script is ready to plug into any 3D truss FEM code.
3. 🎯 Key Points to Remember
Point | Note |
Only axial deformations matter | No bending, no torsion |
Local stiffness is 2×2 | Simple (EA/L)[1 -1; -1 1] |
Transformation T is 2×6 | Simple projection |
Global stiffness is 6×6 | Ready for structural assembly |
4. 🏆 Why This Shortcut is Powerful
No need to define local y', z' axes.
Very efficient for assembling large truss structures.
Easy to program and very fast.
In real-world practice, truss solvers take full advantage of this shortcut for maximum speed.