export class MatrixTranslate { static FTOFIX32 ( x ) { let output = ( ( x ) * 65536.0 ) ; return output ; } static guMtxF2L ( mf ) { let e1 = 0 , e2 = 0 ; let ai = 0 , af = 0 ; let buf = Buffer . alloc ( 0x40 ) ; let offset = 0 ; for ( let i = 0 ; i < 4 ; i ++ ) { for ( let j = 0 ; j < 2 ; j ++ ) { e1 = MatrixTranslate . FTOFIX32 ( mf [ i ] [ j * 2 ] ) ; e2 = MatrixTranslate . FTOFIX32 ( mf [ i ] [ ( j * 2 ) + 1 ] ) ; ai = ( e1 & 0xFFFF0000 ) | ( ( e2 >> 16 ) & 0xFFFF ) ; buf . writeInt32BE ( ai , offset ) ; offset += 0x4 ; } } for ( let i = 0 ; i < 4 ; i ++ ) { for ( let j = 0 ; j < 2 ; j ++ ) { e1 = MatrixTranslate . FTOFIX32 ( mf [ i ] [ j * 2 ] ) ; e2 = MatrixTranslate . FTOFIX32 ( mf [ i ] [ ( j * 2 ) + 1 ] ) ; af = ( ( e1 << 16 ) & 0xFFFF0000 ) | ( e2 & 0xFFFF ) ; buf . writeInt32BE ( af , offset ) ; offset += 0x4 ; } } return buf ; } static guRTSF ( r , p , h , x , y , z , s ) { let sinr , sinp , sinh , cosr , cosp , cosh ; let mf = [ [ ] , [ ] , [ ] , [ ] ] ; r = r * ( Math . PI / 180 ) ; p = p * ( Math . PI / 180 ) ; h = h * ( Math . PI / 180 ) ; sinr = Math . sin ( r ) ; cosr = Math . cos ( r ) ; sinp = Math . sin ( p ) ; cosp = Math . cos ( p ) ; sinh = Math . sin ( h ) ; cosh = Math . cos ( h ) ; mf [ 0 ] [ 0 ] = ( cosp * cosh ) * s ; mf [ 0 ] [ 1 ] = ( cosp * sinh ) * s ; mf [ 0 ] [ 2 ] = ( - sinp ) * s ; mf [ 0 ] [ 3 ] = 0.0 ; mf [ 1 ] [ 0 ] = ( sinr * sinp * cosh - cosr * sinh ) * s ; mf [ 1 ] [ 1 ] = ( sinr * sinp * sinh + cosr * cosh ) * s ; mf [ 1 ] [ 2 ] = ( sinr * cosp ) * s ; mf [ 1 ] [ 3 ] = 0.0 ; mf [ 2 ] [ 0 ] = ( cosr * sinp * cosh + sinr * sinh ) * s ; mf [ 2 ] [ 1 ] = ( cosr * sinp * sinh - sinr * cosh ) * s ; mf [ 2 ] [ 2 ] = ( cosr * cosp ) * s ; mf [ 2 ] [ 3 ] = 0.0 ; mf [ 3 ] [ 0 ] = x ; mf [ 3 ] [ 1 ] = y ; mf [ 3 ] [ 2 ] = z ; mf [ 3 ] [ 3 ] = 1.0 ; return mf ; } }