0001 function fiff_write_coord_trans(fid,trans)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 me='MNE:fiff_write_coord_trans';
0031
0032 if nargin ~= 2
0033 error(me,'Incorrect number of arguments');
0034 end
0035
0036 FIFF_COORD_TRANS=222;
0037 FIFFT_COORD_TRANS_STRUCT=35;
0038 FIFFV_NEXT_SEQ=0;
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 datasize=4*2*12 + 4*2;
0051 count = fwrite(fid,int32(FIFF_COORD_TRANS),'int32');
0052 if count ~= 1
0053 error(me,'write failed');
0054 end
0055 count = fwrite(fid,int32(FIFFT_COORD_TRANS_STRUCT),'int32');
0056 if count ~= 1
0057 error(me,'write failed');
0058 end
0059 count = fwrite(fid,int32(datasize),'int32');
0060 if count ~= 1
0061 error(me,'write failed');
0062 end
0063 count = fwrite(fid,int32(FIFFV_NEXT_SEQ),'int32');
0064 if count ~= 1
0065 error(me,'write failed');
0066 end
0067
0068
0069
0070 count = fwrite(fid,int32(trans.from),'int32');
0071 if count ~= 1
0072 error(me,'write failed');
0073 end
0074 count = fwrite(fid,int32(trans.to),'int32');
0075 if count ~= 1
0076 error(me,'write failed');
0077 end
0078
0079
0080
0081 rot=trans.trans(1:3,1:3)';
0082 move=trans.trans(1:3,4)';
0083 count = fwrite(fid,single(rot),'single');
0084 if count ~= 9
0085 error(me,'write failed');
0086 end
0087 count = fwrite(fid,single(move),'single');
0088 if count ~= 3
0089 error(me,'write failed');
0090 end
0091
0092
0093
0094 trans_inv=inv(trans.trans);
0095 rot=trans_inv(1:3,1:3)';
0096 move=trans_inv(1:3,4)';
0097 count = fwrite(fid,single(rot),'single');
0098 if count ~= 9
0099 error(me,'write failed');
0100 end
0101 count = fwrite(fid,single(move),'single');
0102 if count ~= 3
0103 error(me,'write failed');
0104 end