transformation matrix

I am programming a general solution to piping flexibility. Transferring to the same origin is documented well enough. But I am having trouble
with the transformations from local coordinates to the global. Say the local coordinates are x', y', z' and the global Coordinates are X, Y, Z.
the pipe has end points Start (Xa, Ya, Za) and End (Xb, Yb, Zb) the segment is length L = (Xb - Xa)^2 + (Yb - Ya)^2 + (Zb-Za)^2
The transformation for force F' = A * F
| A00, A01, A02)|
where |A| = | A10, A11, A12)|
| A20, A21, A22)|
| cos(x',X), cos(x', Y) cos(x', Z)|
where |A| = | cos(y',X), cos(y', Y) cos(y', Z)|
| cos(z',X), cos(z', Y) cos(z', Z)|
My local x' coordinate is along the pipe longitudinal axis so the first row should be:: ( Xb - Xa)/L , ( Yb - Ya)/L , ( Zb - Za)/L The Sum of the squares of these terms should equal 1
A10 should be the same magnitude as A01 but I am not sure of its sign.
The y' axis can be oriented in a perpendicular direction to x' and z' is perpendicular to both. I think A11 can have the same value as A10 and probably A22.
Following this logic The second row is
( Yb - Ya)/L, ( Xb - Xa)/L , ?????? Are the sum of these squares also = 1? If so: ( Yb - Ya)/L, ( Xb - Xa)/L , ( Zb - Za)/L
Now the last row:
Maybe someone can review what I have so far. thanks
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

Excuse me doubl00, May I ask why you are transforming to Global? Is the piping leaving the local coordinates?
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
The compliance matrices of the inidividual pipe segments need to be normalized to a common global coordinates system to allow their summation.
Although I think I have solved the problem above, I need to test my solution. I would still appreciate any input the newsgroup community might have.