matrix and rotation angle

hello.
I have a beam(a line)that has an orientation matrix and has a section that is a list of 2d geometric point, a profile.
The section is extruded on the direction of the beam.
The section can be rotated around the direction of the beam.

for example rotation of 45 degree of the section on the z axis:
0.,-0.707106781186547,0.707106781186548
1,0,0
and i extract the third component axis of the matrix with a cross product

or on the x axis

0.707106781186548,0.707106781186547,0.
0,0,1
and cross product

but if the beam has a direction of 45 degree and the section is rotated of 45 degree i have :
0.5,-0.5,0.707106781186548
1,0,0

i would extract the rotation angle of the section from the matrix that is indipendent of the direction of the beam.

is possible?
how?

thanks.