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  

qunrot.c File Reference

#include "vecmat.h"
#include "mrilib.h"

Go to the source code of this file.


Defines

#define FLOAT_TYPE   double
#define ERREX(str)   (fprintf(stderr,"*** %s\n",str),exit(1))

Functions

int main (int argc, char *argv[])

Define Documentation

#define ERREX str       (fprintf(stderr,"*** %s\n",str),exit(1))
 

Definition at line 7 of file qunrot.c.

Referenced by main().

#define FLOAT_TYPE   double
 

Definition at line 1 of file qunrot.c.


Function Documentation

int main int    argc,
char *    argv[]
 

\** File : SUMA.c

Author:
: Ziad Saad Date : Thu Dec 27 16:21:01 EST 2001
Purpose :

Input paramters :

Parameters:
param  Usage : SUMA ( )
Returns :
Returns:
Support :
See also:
OpenGL prog. Guide 3rd edition , varray.c from book's sample code
Side effects :

Definition at line 9 of file qunrot.c.

References a, argc, c, ERREX, LOAD_FVEC3, malloc, THD_mat33::mat, THD_vecmat::mm, MRI_FLOAT_PTR, mri_free(), mri_read_ascii(), MV_format_fval(), MRI_IMAGE::nx, MRI_IMAGE::ny, THD_vecmat::vv, and THD_fvec3::xyz.

00010 {
00011    MRI_IMAGE * vecim ;
00012    float * vecar ;
00013    THD_fvec3 * xx , * yy ;
00014    int nvec , ii ;
00015    THD_vecmat rt ;
00016    char a[32],b[32],c[32],d[32] , *s ;
00017 
00018    if( argc < 2 || strcmp(argv[1],"-help") == 0 ){
00019       printf("Usage: 3dTagalign vecfile1 vecfile2\n") ; exit(0) ;
00020    }
00021 
00022    /*-*/
00023 
00024    vecim = mri_read_ascii( argv[1] ) ;
00025    if( vecim == NULL ) ERREX("Can't open vecfile1\n") ;
00026    if( vecim->nx != 3 || vecim->ny < 4 ) ERREX("vecfile1 badly formed") ;
00027    nvec = vecim->ny ;
00028    vecar = MRI_FLOAT_PTR(vecim) ;
00029 
00030    xx = (THD_fvec3 *) malloc( sizeof(THD_fvec3) * nvec ) ;
00031    for( ii=0 ; ii < nvec ; ii++ ){
00032       LOAD_FVEC3( xx[ii] , vecar[3*ii+0],vecar[3*ii+1],vecar[3*ii+2]) ;
00033    }
00034    mri_free(vecim) ;
00035 
00036    /*-*/
00037 
00038    vecim = mri_read_ascii( argv[2] ) ;
00039    if( vecim == NULL ) ERREX("Can't open vecfile2\n") ;
00040    if( vecim->nx != 3 || vecim->ny != nvec ) ERREX("vecfile2 badly formed") ;
00041    vecar = MRI_FLOAT_PTR(vecim) ;
00042 
00043    yy = (THD_fvec3 *) malloc( sizeof(THD_fvec3) * nvec ) ;
00044    for( ii=0 ; ii < nvec ; ii++ ){
00045       LOAD_FVEC3( yy[ii] , vecar[3*ii+0],vecar[3*ii+1],vecar[3*ii+2]) ;
00046    }
00047    mri_free(vecim) ;
00048 
00049    rt = LSQ_rot_trans( nvec , xx , yy , NULL ) ;
00050 
00051    for( ii=0 ; ii < 3 ; ii++ ){
00052       s = MV_format_fval( rt.mm.mat[ii][0] ) ; strcpy(a,s) ;
00053       s = MV_format_fval( rt.mm.mat[ii][1] ) ; strcpy(b,s) ;
00054       s = MV_format_fval( rt.mm.mat[ii][2] ) ; strcpy(c,s) ;
00055       s = MV_format_fval( rt.vv.xyz[ii]    ) ; strcpy(d,s) ;
00056       printf("%s %s %s %s\n",a,b,c,d) ;
00057    }
00058 
00059    exit(0) ;
00060 }
 

Powered by Plone

This site conforms to the following standards: