Subversion Repositories AndroidProjects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
203 chris 1
/*
2
 * PROJECT: NyARToolkit
3
 * --------------------------------------------------------------------------------
4
 * This work is based on the original ARToolKit developed by
5
 *   Hirokazu Kato
6
 *   Mark Billinghurst
7
 *   HITLab, University of Washington, Seattle
8
 * http://www.hitl.washington.edu/artoolkit/
9
 *
10
 * The NyARToolkit is Java version ARToolkit class library.
11
 * Copyright (C)2008 R.Iizuka
12
 *
13
 * This program is free software; you can redistribute it and/or
14
 * modify it under the terms of the GNU General Public License
15
 * as published by the Free Software Foundation; either version 2
16
 * of the License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this framework; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 *
27
 * For further information please contact.
28
 *      http://nyatla.jp/nyatoolkit/
29
 *      <airmail(at)ebony.plala.or.jp>
30
 *
31
 */
32
package jp.nyatla.nyartoolkit.core;
33
 
34
import jp.nyatla.nyartoolkit.NyARException;
35
import jp.nyatla.util.DoubleValue;
36
 
37
public class NyARTransMat_O1 implements NyARTransMat {
38
        private final static int AR_FITTING_TO_IDEAL = 0;// #define
39
        // AR_FITTING_TO_IDEAL 0
40
        private final static int AR_FITTING_TO_INPUT = 1;// #define
41
        // AR_FITTING_TO_INPUT 1
42
        private final static int arFittingMode = AR_FITTING_TO_INPUT;
43
 
44
        private final static int AR_GET_TRANS_MAT_MAX_LOOP_COUNT = 5;// #define
45
        // AR_GET_TRANS_MAT_MAX_LOOP_COUNT
46
        // 5
47
        private final static double AR_GET_TRANS_MAT_MAX_FIT_ERROR = 1.0;// #define
48
        // AR_GET_TRANS_MAT_MAX_FIT_ERROR
49
        // 1.0
50
        private final static double AR_GET_TRANS_CONT_MAT_MAX_FIT_ERROR = 1.0;
51
        private final static int P_MAX = 10;// 頂点の数(4で十分だけどなんとなく10)//#define P_MAX
52
        // 500
53
        private final static int NUMBER_OF_VERTEX = 4;// 処理対象の頂点数
54
        private final NyARTransRot transrot;
55
        private final double[] center = { 0.0, 0.0 };
56
        private final NyARParam param;
57
 
58
        // private final NyARMat result_mat=new NyARMat(3,4);
59
        public NyARTransMat_O1(NyARParam i_param) throws NyARException {
60
                param = i_param;
61
                transrot = new NyARTransRot_O3(i_param, NUMBER_OF_VERTEX);
62
 
63
        }
64
 
65
        public void setCenter(double i_x, double i_y) {
66
                center[0] = i_x;
67
                center[1] = i_x;
68
        }
69
 
70
        // public NyARMat getTransformationMatrix()
71
        // {
72
        // return result_mat;
73
        // }
74
 
75
        private final double[][] wk_transMat_pos3d = new double[P_MAX][3];// pos3d[P_MAX][3];
76
        private final double[][] wk_transMat_ppos2d = new double[4][2];
77
        private final double[][] wk_transMat_ppos3d = new double[4][2];
78
        private final double[] wk_transMat_off = new double[3];
79
 
80
        /**
81
         * double arGetTransMat( ARMarkerInfo *marker_info,double center[2], double
82
         * width, double conv[3][4] ) 関数の置き換え。 保持している変換行列を更新する。
83
         *
84
         * @param square
85
         *            計算対象のNyARSquareオブジェクト
86
         * @param i_direction
87
         *            マーカーの方向
88
         * @param i_width
89
         *            マーカーのサイズ(mm)
90
         * @param o_result_conv
91
         *            変換行列を受け取るオブジェクトを指定します。
92
         * @return
93
         * @throws NyARException
94
         */
95
        public double transMat(NyARSquare square, int i_direction, double i_width,
96
                        NyARTransMatResult o_result_conv) throws NyARException {
97
                double[][] ppos2d = wk_transMat_ppos2d;
98
                double[][] ppos3d = wk_transMat_ppos3d;
99
                double[] off = wk_transMat_off;
100
                double[][] pos3d = wk_transMat_pos3d;
101
                int dir;
102
                double err = -1;
103
 
104
                transrot.initRot(square, i_direction);
105
 
106
                dir = i_direction;
107
                ppos2d[0][0] = square.sqvertex[(4 - dir) % 4][0];
108
                ppos2d[0][1] = square.sqvertex[(4 - dir) % 4][1];
109
                ppos2d[1][0] = square.sqvertex[(5 - dir) % 4][0];
110
                ppos2d[1][1] = square.sqvertex[(5 - dir) % 4][1];
111
                ppos2d[2][0] = square.sqvertex[(6 - dir) % 4][0];
112
                ppos2d[2][1] = square.sqvertex[(6 - dir) % 4][1];
113
                ppos2d[3][0] = square.sqvertex[(7 - dir) % 4][0];
114
                ppos2d[3][1] = square.sqvertex[(7 - dir) % 4][1];
115
                ppos3d[0][0] = center[0] - i_width / 2.0;
116
                ppos3d[0][1] = center[1] + i_width / 2.0;
117
                ppos3d[1][0] = center[0] + i_width / 2.0;
118
                ppos3d[1][1] = center[1] + i_width / 2.0;
119
                ppos3d[2][0] = center[0] + i_width / 2.0;
120
                ppos3d[2][1] = center[1] - i_width / 2.0;
121
                ppos3d[3][0] = center[0] - i_width / 2.0;
122
                ppos3d[3][1] = center[1] - i_width / 2.0;
123
 
124
                // arGetTransMat3の前段処理(pos3dとoffを初期化)
125
                arGetTransMat3_initPos3d(ppos3d, pos3d, off);
126
 
127
                for (int i = 0; i < AR_GET_TRANS_MAT_MAX_LOOP_COUNT; i++) {
128
                        err = arGetTransMat3(ppos2d, pos3d, off, o_result_conv);
129
                        if (err < AR_GET_TRANS_MAT_MAX_FIT_ERROR) {
130
                                break;
131
                        }
132
                }
133
 
134
                return err;
135
        }
136
 
137
        /**
138
         * transMatContinue用のワーク
139
         */
140
        private final NyARTransMatResult wk_transMatContinue_result = new NyARTransMatResult();
141
 
142
        /**
143
         * double arGetTransMatCont( ARMarkerInfo *marker_info, double
144
         * prev_conv[3][4],double center[2], double width, double conv[3][4] )
145
         *
146
         * @param i_square
147
         * @param i_direction
148
         *            マーカーの方位を指定する。
149
         * @param i_width
150
         * @param io_result_conv
151
         *            計算履歴を持つNyARTransMatResultオブジェクトを指定する。
152
         *            履歴を持たない場合は、transMatと同じ処理を行う。
153
         * @return
154
         * @throws NyARException
155
         */
156
        public double transMatContinue(NyARSquare i_square, int i_direction,
157
                        double i_width, NyARTransMatResult io_result_conv)
158
                        throws NyARException {
159
                // io_result_convが初期値なら、transMatで計算する。
160
                if (!io_result_conv.hasValue()) {
161
                        return this
162
                                        .transMat(i_square, i_direction, i_width, io_result_conv);
163
                }
164
 
165
                double err1, err2;
166
                int i, dir;
167
                double[][] ppos2d = wk_transMat_ppos2d;
168
                double[][] ppos3d = wk_transMat_ppos3d;
169
                double[] off = wk_transMat_off;
170
                double[][] pos3d = wk_transMat_pos3d;
171
 
172
                // arGetTransMatContSub計算部分
173
                transrot.initRotByPrevResult(io_result_conv);
174
 
175
                dir = i_direction;
176
                ppos2d[0][0] = i_square.sqvertex[(4 - dir) % 4][0];
177
                ppos2d[0][1] = i_square.sqvertex[(4 - dir) % 4][1];
178
                ppos2d[1][0] = i_square.sqvertex[(5 - dir) % 4][0];
179
                ppos2d[1][1] = i_square.sqvertex[(5 - dir) % 4][1];
180
                ppos2d[2][0] = i_square.sqvertex[(6 - dir) % 4][0];
181
                ppos2d[2][1] = i_square.sqvertex[(6 - dir) % 4][1];
182
                ppos2d[3][0] = i_square.sqvertex[(7 - dir) % 4][0];
183
                ppos2d[3][1] = i_square.sqvertex[(7 - dir) % 4][1];
184
                ppos3d[0][0] = center[0] - i_width / 2.0;
185
                ppos3d[0][1] = center[1] + i_width / 2.0;
186
                ppos3d[1][0] = center[0] + i_width / 2.0;
187
                ppos3d[1][1] = center[1] + i_width / 2.0;
188
                ppos3d[2][0] = center[0] + i_width / 2.0;
189
                ppos3d[2][1] = center[1] - i_width / 2.0;
190
                ppos3d[3][0] = center[0] - i_width / 2.0;
191
                ppos3d[3][1] = center[1] - i_width / 2.0;
192
 
193
                // arGetTransMat3の前段処理(pos3dとoffを初期化)
194
                arGetTransMat3_initPos3d(ppos3d, pos3d, off);
195
 
196
                err1 = err2 = -1;
197
                for (i = 0; i < AR_GET_TRANS_MAT_MAX_LOOP_COUNT; i++) {
198
                        err1 = arGetTransMat3(ppos2d, pos3d, off, io_result_conv);
199
                        if (err1 < AR_GET_TRANS_MAT_MAX_FIT_ERROR) {
200
                                // 十分な精度を達成できたらブレーク
201
                                break;
202
                        }
203
                }
204
 
205
                // エラー値が許容範囲でなければTransMatをやり直し
206
                if (err1 > AR_GET_TRANS_CONT_MAT_MAX_FIT_ERROR) {
207
                        NyARTransMatResult result2 = this.wk_transMatContinue_result;
208
                        // transMatを実行
209
                        transrot.initRot(i_square, i_direction);
210
                        err2 = transMat(i_square, i_direction, i_width, result2);
211
                        // transmMatここまで
212
                        if (err2 < err1) {
213
                                io_result_conv.copyFrom(result2);
214
                                err1 = err2;
215
                        }
216
                }
217
                return err1;
218
        }
219
 
220
        private final double[] wk_arGetTransMat3_initPos3d_pmax = new double[3];
221
        private final double[] wk_arGetTransMat3_initPos3d_pmin = new double[3];
222
 
223
        /**
224
         * arGetTransMat3関数の前処理部分。i_ppos3dから、o_pos3dとoffを計算する。
225
         * 計算結果から再帰的に変更される可能性が無いので、切り離し。
226
         *
227
         * @param i_ppos3d
228
         *            入力配列[num][3]
229
         * @param o_pos3d
230
         *            出力配列[P_MAX][3]
231
         * @param o_off
232
         *            [3]
233
         * @throws NyARException
234
         */
235
        private final void arGetTransMat3_initPos3d(double i_ppos3d[][],
236
                        double[][] o_pos3d, double[] o_off) throws NyARException {
237
                double[] pmax = wk_arGetTransMat3_initPos3d_pmax;// new double[3];
238
                double[] pmin = wk_arGetTransMat3_initPos3d_pmin;// new
239
                // double[3];//double
240
                // off[3], pmax[3],
241
                // pmin[3];
242
                int i;
243
                pmax[0] = pmax[1] = pmax[2] = -10000000000.0;
244
                pmin[0] = pmin[1] = pmin[2] = 10000000000.0;
245
                for (i = 0; i < NUMBER_OF_VERTEX; i++) {
246
                        if (i_ppos3d[i][0] > pmax[0]) {
247
                                pmax[0] = i_ppos3d[i][0];
248
                        }
249
                        if (i_ppos3d[i][0] < pmin[0]) {
250
                                pmin[0] = i_ppos3d[i][0];
251
                        }
252
                        if (i_ppos3d[i][1] > pmax[1]) {
253
                                pmax[1] = i_ppos3d[i][1];
254
                        }
255
                        if (i_ppos3d[i][1] < pmin[1]) {
256
                                pmin[1] = i_ppos3d[i][1];
257
                        }
258
                        /*
259
                         * オリジナルでもコメントアウト if( ppos3d[i][2] > pmax[2] ) pmax[2] =
260
                         * ppos3d[i][2]; if( ppos3d[i][2] < pmin[2] ) pmin[2] =
261
                         * ppos3d[i][2];
262
                         */
263
                }
264
                o_off[0] = -(pmax[0] + pmin[0]) / 2.0;
265
                o_off[1] = -(pmax[1] + pmin[1]) / 2.0;
266
                o_off[2] = -(pmax[2] + pmin[2]) / 2.0;
267
 
268
                double[] o_pos3d_pt;
269
                double[] i_pos_pd_pt;
270
                for (i = 0; i < NUMBER_OF_VERTEX; i++) {
271
                        o_pos3d_pt = o_pos3d[i];
272
                        i_pos_pd_pt = i_ppos3d[i];
273
                        o_pos3d_pt[0] = i_pos_pd_pt[0] + o_off[0];
274
                        o_pos3d_pt[1] = i_pos_pd_pt[1] + o_off[1];
275
                        o_pos3d_pt[2] = 0.0;
276
                }
277
        }
278
 
279
        /**
280
         * double arGetTransMat3( double rot[3][3], double ppos2d[][2],double
281
         * ppos3d[][2], int num, double conv[3][4],double *dist_factor, double
282
         * cpara[3][4] ) STEP 414->
283
         *
284
         * @param ppos2d
285
         * @param i_pos3d
286
         * @param i_off
287
         * @param num
288
         * @return
289
         * @throws NyARException
290
         */
291
        private final double arGetTransMat3(double ppos2d[][],
292
                        final double i_pos3d[][], final double i_off[],
293
                        NyARTransMatResult o_result_conv) throws NyARException {
294
 
295
                double ret;
296
                ret = arGetTransMatSub(ppos2d, i_pos3d, i_off, o_result_conv);
297
 
298
                // double[][] conv=o_result_conv.getArray();
299
                // double[] rot=transrot.getArray();
300
                // for(int i=0;i<3;i++){
301
                // conv[i][0] = rot[i*3+0];
302
                // conv[i][1] = rot[i*3+1];
303
                // conv[i][2] = rot[i*3+2];
304
                // }
305
                // conv[0][3] = conv[0][0]*i_off[0] + conv[0][1]*i_off[1] +
306
                // conv[0][2]*i_off[2] + conv[0][3];
307
                // conv[1][3] = conv[1][0]*i_off[0] + conv[1][1]*i_off[1] +
308
                // conv[1][2]*i_off[2] + conv[1][3];
309
                // conv[2][3] = conv[2][0]*i_off[0] + conv[2][1]*i_off[1] +
310
                // conv[2][2]*i_off[2] + conv[2][3];
311
                return ret;
312
        }
313
 
314
        private final NyARMat wk_arGetTransMatSub_mat_a = new NyARMat(
315
                        NUMBER_OF_VERTEX * 2, 3);
316
        private final NyARMat wk_arGetTransMatSub_mat_b = new NyARMat(3,
317
                        NUMBER_OF_VERTEX * 2);
318
        private final NyARMat wk_arGetTransMatSub_mat_c = new NyARMat(
319
                        NUMBER_OF_VERTEX * 2, 1);
320
        private final NyARMat wk_arGetTransMatSub_mat_d = new NyARMat(3, 3);
321
        private final NyARMat wk_arGetTransMatSub_mat_e = new NyARMat(3, 1);
322
        private final NyARMat wk_arGetTransMatSub_mat_f = new NyARMat(3, 1);
323
        private final double[] wk_arGetTransMatSub_trans = new double[3];
324
        private final double[][] wk_arGetTransMatSub_pos2d = new double[P_MAX][2];// pos2d[P_MAX][2];
325
        private final DoubleValue wk_arGetTransMatSub_a1 = new DoubleValue();
326
        private final DoubleValue wk_arGetTransMatSub_a2 = new DoubleValue();
327
 
328
        /**
329
         * static double arGetTransMatSub( double rot[3][3], double
330
         * ppos2d[][2],double pos3d[][3], int num, double conv[3][4],double
331
         * *dist_factor, double cpara[3][4] ) Optimize:2008.04.20:STEP[1033→1004]
332
         *
333
         * @param i_ppos2d
334
         * @param i_pos3d
335
         * @return
336
         * @throws NyARException
337
         */
338
        private final double arGetTransMatSub(double i_ppos2d[][],
339
                        double i_pos3d[][], double[] i_off, NyARTransMatResult o_result_conv)
340
                        throws NyARException {
341
                double[][] pos2d = wk_arGetTransMatSub_pos2d;
342
                double cpara[] = param.get34Array();
343
                NyARMat mat_a, mat_b, mat_c, mat_d, mat_e, mat_f;// ARMat *mat_a,
344
                // *mat_b, *mat_c,
345
                // *mat_d, *mat_e,
346
                // *mat_f;
347
 
348
                double wx, wy, wz;
349
                double ret;
350
                int i;
351
                double[] po2d_pt;
352
 
353
                mat_a = this.wk_arGetTransMatSub_mat_a;
354
                // mat_a.realloc(NUMBER_OF_VERTEX*2,3);
355
                double[][] a_array = mat_a.getArray();
356
 
357
                mat_b = this.wk_arGetTransMatSub_mat_b;
358
                // mat_b.realloc(3,NUMBER_OF_VERTEX*2);
359
                double[][] b_array = mat_b.getArray();
360
 
361
                DoubleValue a1 = wk_arGetTransMatSub_a1;
362
                DoubleValue a2 = wk_arGetTransMatSub_a2;
363
                if (arFittingMode == AR_FITTING_TO_INPUT) {
364
                        for (i = 0; i < NUMBER_OF_VERTEX; i++) {
365
                                param.ideal2Observ(i_ppos2d[i][0], i_ppos2d[i][1], a1, a2);// arParamIdeal2Observ(dist_factor,
366
                                // ppos2d[i][0],
367
                                // ppos2d[i][1],&pos2d[i][0],
368
                                // &pos2d[i][1]);
369
                                po2d_pt = pos2d[i];
370
                                po2d_pt[0] = a1.value;
371
                                po2d_pt[1] = a2.value;
372
                        }
373
                } else {
374
                        for (i = 0; i < NUMBER_OF_VERTEX; i++) {
375
                                po2d_pt = pos2d[i];
376
                                pos2d[i][0] = i_ppos2d[i][0];
377
                                pos2d[i][1] = i_ppos2d[i][1];
378
                        }
379
                }
380
                mat_c = this.wk_arGetTransMatSub_mat_c;// 次処理で値をもらうので、初期化の必要は無い。
381
                // mat_c.realloc(NUMBER_OF_VERTEX*2,1);
382
                double[][] c_array = mat_c.getArray();
383
                double[] rot = transrot.getArray();
384
                double[] i_pos3d_pt;
385
                int x2;
386
                for (i = 0; i < NUMBER_OF_VERTEX; i++) {
387
                        x2 = i * 2;
388
                        i_pos3d_pt = i_pos3d[i];
389
                        po2d_pt = pos2d[i];
390
                        wx = rot[0] * i_pos3d_pt[0] + rot[1] * i_pos3d_pt[1] + rot[2]
391
                                        * i_pos3d_pt[2];
392
                        wy = rot[3] * i_pos3d_pt[0] + rot[4] * i_pos3d_pt[1] + rot[5]
393
                                        * i_pos3d_pt[2];
394
                        wz = rot[6] * i_pos3d_pt[0] + rot[7] * i_pos3d_pt[1] + rot[8]
395
                                        * i_pos3d_pt[2];
396
                        // </Optimize>
397
                        a_array[x2][0] = b_array[0][x2] = cpara[0 * 4 + 0];// mat_a->m[j*6+0]
398
                        // =
399
                        // mat_b->m[num*0+j*2]
400
                        // =
401
                        // cpara[0][0];
402
                        a_array[x2][1] = b_array[1][x2] = cpara[0 * 4 + 1];// mat_a->m[j*6+1]
403
                        // =
404
                        // mat_b->m[num*2+j*2]
405
                        // =
406
                        // cpara[0][1];
407
                        a_array[x2][2] = b_array[2][x2] = cpara[0 * 4 + 2] - po2d_pt[0];// mat_a->m[j*6+2]
408
                        // =
409
                        // mat_b->m[num*4+j*2]
410
                        // =
411
                        // cpara[0][2]
412
                        // -
413
                        // pos2d[j][0];
414
                        a_array[x2 + 1][0] = b_array[0][x2 + 1] = 0.0;// mat_a->m[j*6+3] =
415
                        // mat_b->m[num*0+j*2+1]
416
                        // = 0.0;
417
                        a_array[x2 + 1][1] = b_array[1][x2 + 1] = cpara[1 * 4 + 1];// mat_a->m[j*6+4]
418
                        // =
419
                        // mat_b->m[num*2+j*2+1]
420
                        // =
421
                        // cpara[1][1];
422
                        a_array[x2 + 1][2] = b_array[2][x2 + 1] = cpara[1 * 4 + 2]
423
                                        - po2d_pt[1];// mat_a->m[j*6+5] = mat_b->m[num*4+j*2+1] =
424
                        // cpara[1][2] - pos2d[j][1];
425
                        c_array[x2][0] = wz * po2d_pt[0] - cpara[0 * 4 + 0] * wx
426
                                        - cpara[0 * 4 + 1] * wy - cpara[0 * 4 + 2] * wz;// mat_c->m[j*2+0]
427
                        // = wz *
428
                        // pos2d[j][0]-
429
                        // cpara[0][0]*wx
430
                        // -
431
                        // cpara[0][1]*wy
432
                        // -
433
                        // cpara[0][2]*wz;
434
                        c_array[x2 + 1][0] = wz * po2d_pt[1] - cpara[1 * 4 + 1] * wy
435
                                        - cpara[1 * 4 + 2] * wz;// mat_c->m[j*2+1] = wz *
436
                        // pos2d[j][1]- cpara[1][1]*wy -
437
                        // cpara[1][2]*wz;
438
                }
439
                mat_d = this.wk_arGetTransMatSub_mat_d;// 次処理で値をもらうので、初期化の必要は無い。
440
                mat_e = this.wk_arGetTransMatSub_mat_e;// 次処理で値をもらうので、初期化の必要は無い。
441
                mat_f = this.wk_arGetTransMatSub_mat_f;// 次処理で値をもらうので、初期化の必要は無い。
442
                double[][] f_array = mat_f.getArray();
443
 
444
                mat_d.matrixMul(mat_b, mat_a);
445
                mat_e.matrixMul(mat_b, mat_c);
446
                mat_d.matrixSelfInv();
447
                mat_f.matrixMul(mat_d, mat_e);
448
 
449
                double[] trans = wk_arGetTransMatSub_trans;// double trans[3];
450
                trans[0] = f_array[0][0];// trans[0] = mat_f->m[0];
451
                trans[1] = f_array[1][0];
452
                trans[2] = f_array[2][0];// trans[2] = mat_f->m[2];
453
 
454
                ret = transrot.modifyMatrix(trans, i_pos3d, pos2d);
455
                for (i = 0; i < NUMBER_OF_VERTEX; i++) {
456
                        x2 = i * 2;
457
                        i_pos3d_pt = i_pos3d[i];
458
                        po2d_pt = pos2d[i];
459
                        // <Optimize>
460
                        // wx = rot[0][0] * pos3d[j][0]+ rot[0][1] * pos3d[j][1]+ rot[0][2]
461
                        // * pos3d[j][2];
462
                        // wy = rot[1][0] * pos3d[j][0]+ rot[1][1] * pos3d[j][1]+ rot[1][2]
463
                        // * pos3d[j][2];
464
                        // wz = rot[2][0] * pos3d[j][0]+ rot[2][1] * pos3d[j][1]+ rot[2][2]
465
                        // * pos3d[j][2];
466
                        wx = rot[0] * i_pos3d_pt[0] + rot[1] * i_pos3d_pt[1] + rot[2]
467
                                        * i_pos3d_pt[2];
468
                        wy = rot[3] * i_pos3d_pt[0] + rot[4] * i_pos3d_pt[1] + rot[5]
469
                                        * i_pos3d_pt[2];
470
                        wz = rot[6] * i_pos3d_pt[0] + rot[7] * i_pos3d_pt[1] + rot[8]
471
                                        * i_pos3d_pt[2];
472
                        // </Optimize>
473
                        a_array[x2][0] = b_array[0][x2] = cpara[0 * 4 + 0];// mat_a->m[j*6+0]
474
                        // =
475
                        // mat_b->m[num*0+j*2]
476
                        // =
477
                        // cpara[0][0];
478
                        a_array[x2][1] = b_array[1][x2] = cpara[0 * 4 + 1];// mat_a->m[j*6+1]
479
                        // =
480
                        // mat_b->m[num*2+j*2]
481
                        // =
482
                        // cpara[0][1];
483
                        a_array[x2][2] = b_array[2][x2] = cpara[0 * 4 + 2] - po2d_pt[0];// mat_a->m[j*6+2]
484
                        // =
485
                        // mat_b->m[num*4+j*2]
486
                        // =
487
                        // cpara[0][2]
488
                        // -
489
                        // pos2d[j][0];
490
                        a_array[x2 + 1][0] = b_array[0][x2 + 1] = 0.0;// mat_a->m[j*6+3] =
491
                        // mat_b->m[num*0+j*2+1]
492
                        // = 0.0;
493
                        a_array[x2 + 1][1] = b_array[1][x2 + 1] = cpara[1 * 4 + 1];// mat_a->m[j*6+4]
494
                        // =
495
                        // mat_b->m[num*2+j*2+1]
496
                        // =
497
                        // cpara[1][1];
498
                        a_array[x2 + 1][2] = b_array[2][x2 + 1] = cpara[1 * 4 + 2]
499
                                        - po2d_pt[1];// mat_a->m[j*6+5] = mat_b->m[num*4+j*2+1] =
500
                        // cpara[1][2] - pos2d[j][1];
501
                        c_array[x2][0] = wz * po2d_pt[0] - cpara[0 * 4 + 0] * wx
502
                                        - cpara[0 * 4 + 1] * wy - cpara[0 * 4 + 2] * wz;// mat_c->m[j*2+0]
503
                        // = wz *
504
                        // pos2d[j][0]-
505
                        // cpara[0][0]*wx
506
                        // -
507
                        // cpara[0][1]*wy
508
                        // -
509
                        // cpara[0][2]*wz;
510
                        c_array[x2 + 1][0] = wz * po2d_pt[1] - cpara[1 * 4 + 1] * wy
511
                                        - cpara[1 * 4 + 2] * wz;// mat_c->m[j*2+1] = wz *
512
                        // pos2d[j][1]- cpara[1][1]*wy -
513
                        // cpara[1][2]*wz;
514
                }
515
 
516
                mat_d.matrixMul(mat_b, mat_a);
517
                mat_e.matrixMul(mat_b, mat_c);
518
                mat_d.matrixSelfInv();
519
                mat_f.matrixMul(mat_d, mat_e);
520
 
521
                trans[0] = f_array[0][0];// trans[0] = mat_f->m[0];
522
                trans[1] = f_array[1][0];
523
                trans[2] = f_array[2][0];// trans[2] = mat_f->m[2];
524
 
525
                ret = transrot.modifyMatrix(trans, i_pos3d, pos2d);
526
                // 変換行列を保存
527
                o_result_conv.updateMatrixValue(this.transrot, i_off, trans);
528
 
529
                // double[][] conv=o_result_conv.getArray();
530
                // for( i = 2; i >=0; i-- ) {//<Optimize/>for( j = 0; j < 3; j++ ) {
531
                // //<Optimize>
532
                // //for( i = 0; i < 3; i++ ){
533
                // // conv[j][i] = rot[j][i];
534
                // //}
535
                // conv[i][0] = rot[i*3+0];
536
                // conv[i][1] = rot[i*3+1];
537
                // conv[i][2] = rot[i*3+2];
538
                // //</Optimize>
539
                // conv[i][3] = trans[i];
540
                // }
541
                return ret;
542
        }
543
}