Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

qrot.c

Go to the documentation of this file.
00001 #include "mrilib.h"
00002 
00003 #define ERREX(str) (fprintf(stderr,"*** %s\n",str),exit(1))
00004 
00005 int main( int argc , char * argv[] )
00006 {
00007    THD_mat33 mat ;
00008    THD_fvec3 tran , vec ;
00009    MRI_IMAGE * matim , * vecim ;
00010    float     * matar , * vecar ;
00011    int nvec , ii ;
00012    char a[32],b[32],c[32] , *s ;
00013 
00014    if( argc < 3 || strcmp(argv[1],"-help") == 0 ){
00015       printf("Usage: qrot matfile vecfile > outvecfile \n") ; exit(0) ;
00016    }
00017 
00018    matim = mri_read_ascii( argv[1] ) ;
00019    if( matim == NULL ) ERREX("Can't open matfile!") ;
00020    if( matim->nx != 4 || matim->ny != 3 ) ERREX("matfile not 4x3!") ;
00021 
00022    matar = MRI_FLOAT_PTR(matim) ;
00023    LOAD_MAT(mat,matar[0],matar[1],matar[2],
00024                 matar[4],matar[5],matar[6],
00025                 matar[8],matar[9],matar[10] ) ;
00026    LOAD_FVEC3(tran,matar[3],matar[7],matar[11]) ;
00027 
00028    vecim = mri_read_ascii( argv[2] ) ;
00029    if( vecim == NULL ) ERREX("Can't open vecfile!") ;
00030    if( vecim->nx != 3 ) ERREX("vecfile not 3xN!") ;
00031 
00032    vecar = MRI_FLOAT_PTR(vecim) ;
00033    nvec = vecim->ny ;
00034    for( ii=0 ; ii < nvec ; ii++ ){
00035       LOAD_FVEC3(vec,vecar[3*ii+0],vecar[3*ii+1],vecar[3*ii+2]) ;
00036       vec = MATVEC(mat,vec) ;
00037       vec = ADD_FVEC3(vec,tran) ;
00038       s = MV_format_fval( vec.xyz[0] ) ; strcpy(a,s) ;
00039       s = MV_format_fval( vec.xyz[1] ) ; strcpy(b,s) ;
00040       s = MV_format_fval( vec.xyz[2] ) ; strcpy(c,s) ;
00041       printf("%s %s %s\n",a,b,c) ;
00042    }
00043    exit(0) ;
00044 }
 

Powered by Plone

This site conforms to the following standards: