Doxygen Source Code Documentation
qrot.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Defines | |
#define | ERREX(str) (fprintf(stderr,"*** %s\n",str),exit(1)) |
Functions | |
int | main (int argc, char *argv[]) |
Define Documentation
|
Definition at line 3 of file qrot.c. Referenced by main(). |
Function Documentation
|
\** File : SUMA.c
Input paramters :
Definition at line 5 of file qrot.c. References a, ADD_FVEC3, argc, c, ERREX, LOAD_FVEC3, LOAD_MAT, mat, MATVEC, MRI_FLOAT_PTR, mri_read_ascii(), MV_format_fval(), MRI_IMAGE::nx, MRI_IMAGE::ny, vec, and THD_fvec3::xyz.
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 } |