OSDN Git Service

[tag]NyARToolkit/2.5.1
[nyartoolkit-and/nyartoolkit-and.git] / tags / 2.5.1 / src / jp / nyatla / nyartoolkit / core / param / NyARObserv2IdealMap.java
1 /* \r
2  * PROJECT: NyARToolkit\r
3  * --------------------------------------------------------------------------------\r
4  * This work is based on the original ARToolKit developed by\r
5  *   Hirokazu Kato\r
6  *   Mark Billinghurst\r
7  *   HITLab, University of Washington, Seattle\r
8  * http://www.hitl.washington.edu/artoolkit/\r
9  *\r
10  * The NyARToolkit is Java edition ARToolKit class library.\r
11  * Copyright (C)2008-2009 Ryo Iizuka\r
12  *\r
13  * This program is free software: you can redistribute it and/or modify\r
14  * it under the terms of the GNU General Public License as published by\r
15  * the Free Software Foundation, either version 3 of the License, or\r
16  * (at your option) any later version.\r
17  * \r
18  * This program is distributed in the hope that it will be useful,\r
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
21  * GNU General Public License for more details.\r
22  *\r
23  * You should have received a copy of the GNU General Public License\r
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
25  * \r
26  * For further information please contact.\r
27  *      http://nyatla.jp/nyatoolkit/\r
28  *      <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
29  * \r
30  */\r
31 package jp.nyatla.nyartoolkit.core.param;\r
32 \r
33 import jp.nyatla.nyartoolkit.core.types.NyARDoublePoint2d;\r
34 import jp.nyatla.nyartoolkit.core.types.*;\r
35 \r
36 /**\r
37  * 歪み矯正した座標系を格納したクラスです。\r
38  * 2次元ラスタを1次元配列で表現します。\r
39  *\r
40  */\r
41 public class NyARObserv2IdealMap\r
42 {\r
43         protected int _stride;\r
44         protected double[] _mapx;\r
45         protected double[] _mapy;\r
46         public NyARObserv2IdealMap(NyARCameraDistortionFactor i_distfactor,NyARIntSize i_screen_size)\r
47         {\r
48                 NyARDoublePoint2d opoint=new NyARDoublePoint2d();\r
49                 this._mapx=new double[i_screen_size.w*i_screen_size.h];\r
50                 this._mapy=new double[i_screen_size.w*i_screen_size.h];\r
51                 this._stride=i_screen_size.w;\r
52                 int ptr=i_screen_size.h*i_screen_size.w-1;\r
53                 //歪みマップを構築\r
54                 for(int i=i_screen_size.h-1;i>=0;i--)\r
55                 {\r
56                         for(int i2=i_screen_size.w-1;i2>=0;i2--)\r
57                         {\r
58                                 i_distfactor.observ2Ideal(i2,i, opoint);\r
59                                 this._mapx[ptr]=opoint.x;\r
60                                 this._mapy[ptr]=opoint.y;\r
61                                 ptr--;\r
62                         }\r
63                 }\r
64                 return;\r
65         }\r
66         public void observ2Ideal(int ix, int iy, NyARDoublePoint2d o_point)\r
67         {\r
68                 int idx=ix+iy*this._stride;\r
69                 o_point.x=this._mapx[idx];\r
70                 o_point.y=this._mapy[idx];\r
71                 return;\r
72         }\r
73         public void observ2IdealBatch(int[] i_x_coord, int[] i_y_coord,int i_start, int i_num, double[] o_x_coord,double[] o_y_coord,int i_out_start_index)\r
74         {\r
75                 int idx;\r
76                 int ptr=i_out_start_index;\r
77                 final double[] mapx=this._mapx;\r
78                 final double[] mapy=this._mapy;\r
79                 final int stride=this._stride;\r
80                 for (int j = 0; j < i_num; j++){\r
81                         idx=i_x_coord[i_start + j]+i_y_coord[i_start + j]*stride;\r
82                         o_x_coord[ptr]=mapx[idx];\r
83                         o_y_coord[ptr]=mapy[idx];\r
84                         ptr++;\r
85                 }\r
86                 return;\r
87         }       \r
88 }\r