vl_irodr.c
Go to the documentation of this file.
00001 /* file:        irodr.mex.c
00002 ** author:      Andrea Vedaldi
00003 ** description: Inverse rodrigues formula
00004 **/
00005 
00006 /*
00007 Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
00008 All rights reserved.
00009 
00010 This file is part of the VLFeat library and is made available under
00011 the terms of the BSD license (see the COPYING file).
00012 */
00013 
00014 #include <mexutils.h>
00015 
00016 #include <vl/rodrigues.h>
00017 
00018 enum {
00019   IN_R = 0
00020 } ;
00021 
00022 enum {
00023   OUT_OM=0,
00024   OUT_DOM
00025 } ;
00026 
00027 /* -------------------------------------------------------------------
00028 **                                                              Driver
00029 ** ----------------------------------------------------------------- */
00030 
00031 void
00032 mexFunction(int nout, mxArray *out[],
00033             int nin, const mxArray *in[])
00034 {
00035   int k,K ;
00036   double* om_pt ;
00037   double* dom_pt ;
00038   double const * R_pt ;
00039 
00040   /* -----------------------------------------------------------------
00041   **                                               Check the arguments
00042   ** -------------------------------------------------------------- */
00043   if(nin != 1) {
00044     mexErrMsgTxt("Exactly one argument required.") ;
00045   }
00046 
00047   if(!vlmxIsMatrix(in[IN_R],-1,-1)) {
00048     mexErrMsgTxt("R must be a DOUBLE array") ;
00049   }
00050 
00051   K = mxGetNumberOfElements(in[IN_R]) ;
00052   if(K % 9 || K < 9) {
00053     mexErrMsgTxt("The elements of R must be a multiple of 9.") ;
00054   }
00055   K /= 9 ;
00056   R_pt = mxGetPr(in[IN_R]) ;
00057 
00058   /* space for output (OM) */
00059   out[OUT_OM] = mxCreateDoubleMatrix(3,1,mxREAL) ;
00060   om_pt = mxGetPr(out[OUT_OM]) ;
00061 
00062   /* space for optional output (dR) */
00063   dom_pt = NULL ;
00064   if( nout > 1 ) {
00065     if( K == 1 ) {
00066       out[OUT_DOM] = mxCreateDoubleMatrix(3,9,mxREAL) ;
00067     } else {
00068       mwSize dims [3] ;
00069       dims[0] = 3 ; dims[1] = 9 ; dims[2] = K ;
00070       out[OUT_DOM] = mxCreateNumericArray(3,dims,mxDOUBLE_CLASS,mxREAL) ;
00071     }
00072     dom_pt = mxGetPr(out[OUT_DOM]) ;
00073   }
00074 
00075   /* -----------------------------------------------------------------
00076   **                                                           Process
00077   ** -------------------------------------------------------------- */
00078   for(k = 0 ; k < K ; ++k) {
00079     vl_irodrigues(om_pt, dom_pt, R_pt) ;
00080     om_pt  += 3 ;
00081     dom_pt += 3*9 ;
00082     R_pt   += 3*3 ;
00083   }
00084 
00085 }


libvlfeat
Author(s): Andrea Vedaldi
autogenerated on Thu Jun 6 2019 20:25:51