1 | /* file: irodr.mex.c |
---|
2 | ** author: Andrea Vedaldi |
---|
3 | ** description: Inverse rodrigues formula |
---|
4 | **/ |
---|
5 | |
---|
6 | #include<mexutils.c> |
---|
7 | #include"bits/rodrigues.c" |
---|
8 | |
---|
9 | enum { |
---|
10 | IN_R = 0 |
---|
11 | } ; |
---|
12 | |
---|
13 | enum { |
---|
14 | OUT_OM=0, |
---|
15 | OUT_DOM |
---|
16 | } ; |
---|
17 | |
---|
18 | /* ------------------------------------------------------------------- |
---|
19 | ** Driver |
---|
20 | ** ----------------------------------------------------------------- */ |
---|
21 | |
---|
22 | void |
---|
23 | mexFunction(int nout, mxArray *out[], |
---|
24 | int nin, const mxArray *in[]) |
---|
25 | { |
---|
26 | int k,K ; |
---|
27 | double* om_pt ; |
---|
28 | double* dom_pt ; |
---|
29 | double const * R_pt ; |
---|
30 | |
---|
31 | /* ----------------------------------------------------------------- |
---|
32 | ** Check the arguments |
---|
33 | ** -------------------------------------------------------------- */ |
---|
34 | if(nin != 1) { |
---|
35 | mexErrMsgTxt("Exactly one argument required.") ; |
---|
36 | } |
---|
37 | |
---|
38 | if(!uIsRealMatrix(in[IN_R],-1,-1)) { |
---|
39 | mexErrMsgTxt("R must be a DOUBLE array") ; |
---|
40 | } |
---|
41 | |
---|
42 | K = mxGetNumberOfElements(in[IN_R]) ; |
---|
43 | if(K % 9 || K < 9) { |
---|
44 | mexErrMsgTxt("The elements of R must be a multiple of 9.") ; |
---|
45 | } |
---|
46 | K /= 9 ; |
---|
47 | R_pt = mxGetPr(in[IN_R]) ; |
---|
48 | |
---|
49 | /* space for output (OM) */ |
---|
50 | out[OUT_OM] = mxCreateDoubleMatrix(3,1,mxREAL) ; |
---|
51 | om_pt = mxGetPr(out[OUT_OM]) ; |
---|
52 | |
---|
53 | /* space for optional output (dR) */ |
---|
54 | dom_pt = NULL ; |
---|
55 | if( nout > 1 ) { |
---|
56 | if( K == 1 ) { |
---|
57 | out[OUT_DOM] = mxCreateDoubleMatrix(3,9,mxREAL) ; |
---|
58 | } else { |
---|
59 | int dims [3] ; |
---|
60 | dims[0] = 3 ; dims[1] = 9 ; dims[2] = K ; |
---|
61 | out[OUT_DOM] = mxCreateNumericArray(3,dims,mxDOUBLE_CLASS,mxREAL) ; |
---|
62 | } |
---|
63 | dom_pt = mxGetPr(out[OUT_DOM]) ; |
---|
64 | } |
---|
65 | |
---|
66 | /* ----------------------------------------------------------------- |
---|
67 | ** Process |
---|
68 | ** -------------------------------------------------------------- */ |
---|
69 | for(k = 0 ; k < K ; ++k) { |
---|
70 | vl_irodrigues(om_pt, dom_pt, R_pt) ; |
---|
71 | om_pt += 3 ; |
---|
72 | dom_pt += 3*9 ; |
---|
73 | R_pt += 3*3 ; |
---|
74 | } |
---|
75 | |
---|
76 | } |
---|