Well, it is simple and complex in the same time... like anything in 3D, it is based on complex topology mathematic... in this case, orientation matrix is related to Euler angles...
Some educative link :
- Euler angles : http://en.wikipedia.org/wiki/Euler_angles
- Rotation matrix : http://en.wikipedia.org/wiki/Rotation_matrix read first the two dimensional matrix and look at the "common rotations"... once you understand the 2D rotation matrix, you will easily understand the 3D one...
However, if I wanted to make a new missile hardpoint, have it oriented 45 degrees off straight forward and also angled 45 degrees up, I'd be really lost. I'd also be equally hosed if I had to make a (choose facing) missile hardpoint that fired straight up or down
well, some pratice now... first, you wish a "45 degrees off straight foward"... hmmm, i cannot give you a single solution these case since you don't say if it is 45° clockwise or counterclokwise...
any way, it is a y axis rotation... let call is Rya ( rotation from y with a angle a )
Tya=( cos a , 0 , sin a ) ( 0 , 1 , 0 ) ( -sin a , 0 , cos a )
The 0 and 1 will never change in the case of a y axis rotation ( y axis rotation mean that the horizontal plane is rotating )... a 45° rotation will give the following result ( first case is +45°, second one is -45° ) rounded at 6 decimal like in sins
Ty45 = ( 0.707107 , 0 , 0.707107 ) ( 0 , 1 , 0 ) ( -0.707107 , 0 , 0.707107 )
Ty-45 = ( 0.707107 , 0 , -0.707107 ) ( 0 , 1 , 0 ) ( 0.707107 , 0 , 0.707107 )
Now, for the rotation 45 degree up... if i good remember, in sins, the axis Z is for the front... so, a x rotation will make the job for up and down... let call it Txb ( rotation from x with a angle b )
Txb = ( 1 , 0 , 0 ) ( 0 , cos b , -sin b ) ( 0 , sins b , cos b )
Tx45 = ( 1 , 0 , 0 ) ( 0 , 0.707107 , -0.707107 ) ( 0 , 0.707107 , 0.707107 )
For a rotation along the Z axis, formula will be :
Tzc = ( cos c , -sin c , 0 ) ( sin c, cos c , 0 ) ( 0 , 0 , 1 )
in these case c is 0, so
Tz0 = ( 1 , 0 , 0 ) ( 0, 1 , 0 ) ( 0 , 0 , 1 )
So, it is enough easy to calculate matrix for one single axis rotation... combine them is a other problem... The final matrix is a sequence of 3 rotations... Since matrix multiplication don't commute, the order of the rotation will affect the result... because of this, i will use a order who is the norm in 3D topology... for sins case, to be sure, ask dev about the rotation order, it is very possible that y and x order rotation are inverted and i have not time for make practical test on existing model ... rotate first x, followed by y and z in the end... let call these final matrix Txaybzc where a is the rotation angle of x, b is the rotation angle of y and c is the rotation angle of z...
Txaybzc = Tzc * Tya * txb =
( cos a * cos c , sin b * sin a * cos c - cos b * sin c , cos b * sin a * cos c + sin b * sin c )
( cos a * sin c , sin b * sin a * sin c + cos b * cos c , cos b * sin a * sin c - sin b * cos c )
( -sin a , sin b * cos a , cos b * cos a )
If you look at http://en.wikipedia.org/wiki/Euler_angles#Matrix_orientation , my result matrix is from the type ZYX... once you know the matrix orientation used by sins ( 12 possibilities ), you can make the right final matrix... This post give you the needed knowledge for calculate the matrix once you know what matrix orientation sins is using.
Formula for calcul angle rotation from the matrix data is enough simple if you have a calculator with arcsin, arccos, arctan ( windows calculator in scientific mode don't have it )... if you have some basic programming skill, you can perfectly make a tool for calculate matrix from angle and angle from matrix...
For example, in the case of a ZYX matrix, value being
Txaybzc = ( v11 , v12 , v13 ) ( v21 , v22 , v23 ) ( v31 , v32 , v33 )
Pseudo code for find the rotation angle a (x axis ), b ( y axis ), c ( z axis ) will be something like :
IF ABS ( v31 ) <> 1
b1 = -asin ( v31 )
b2 = pi - b1
a1 = atan2 ( v32 / cos b1 , v33 / cos b1 )
a2 = atan2 ( v32 / cos b2 , v33 / cos b2 )
c1 = atan2 ( v21 / cos b1 , v11 / cos b1 )
c2 = atan2 ( v21 / cos b2 , v11 / cos b2 )
else
c = 0
if ( v31 = -1 )
b = pi / 2
a = c + atan2 ( v12 , v13 )
else
b = - pi / 2
a = - c + atan2 ( -v12 , -v13 )
endif
endif
Well, it is a enough long post, with a lot of theory and who don't really solve your problem since we don't know ( yet )the matrix orientation used by sins... but once know, you will be able to calculate matrix for any rotation angle of the 3 axis... or calculate the reverse, find the 3 angles from the matrix... some coding knowledge will allow you to create a tiny software for make the job for you... My pseudo code example is not perfect because i choice to ignore the singularity at the north/south pole... if you have really some interest, i advice you to visit http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/index.htm and explore the full site...