OSDN Git Service

Merge branch 'git-svn'
[nyartoolkit-and/nyartoolkit-and.git] / tags / 2.4.2 / src / jp / nyatla / nyartoolkit / core / types / matrix / NyARDoubleMatrix22.java
1 /* \r
2  * PROJECT: NyARToolkit(Extension)\r
3  * --------------------------------------------------------------------------------\r
4  * The NyARToolkit is Java edition ARToolKit class library.\r
5  * Copyright (C)2008-2009 Ryo Iizuka\r
6  *\r
7  * This program is free software: you can redistribute it and/or modify\r
8  * it under the terms of the GNU General Public License as published by\r
9  * the Free Software Foundation, either version 3 of the License, or\r
10  * (at your option) any later version.\r
11  * \r
12  * This program is distributed in the hope that it will be useful,\r
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15  * GNU General Public License for more details.\r
16  *\r
17  * You should have received a copy of the GNU General Public License\r
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
19  * \r
20  * For further information please contact.\r
21  *      http://nyatla.jp/nyatoolkit/\r
22  *      <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
23  * \r
24  */\r
25 package jp.nyatla.nyartoolkit.core.types.matrix;\r
26 \r
27 public class NyARDoubleMatrix22 implements INyARDoubleMatrix\r
28 {\r
29         public double m00;\r
30         public double m01;\r
31         public double m10;\r
32         public double m11;\r
33         /**\r
34          * 遅いからあんまり使わないでね。\r
35          */\r
36         public void setValue(double[] i_value)\r
37         {\r
38                 this.m00=i_value[0];\r
39                 this.m01=i_value[1];\r
40                 this.m10=i_value[3];\r
41                 this.m11=i_value[4];\r
42                 return;\r
43         }\r
44         /**\r
45          * 遅いからあんまり使わないでね。\r
46          */\r
47         public void getValue(double[] o_value)\r
48         {\r
49                 o_value[0]=this.m00;\r
50                 o_value[1]=this.m01;\r
51                 o_value[3]=this.m10;\r
52                 o_value[4]=this.m11;\r
53                 return;\r
54         }\r
55         public boolean inverse(NyARDoubleMatrix22 i_src)\r
56         {\r
57                 final double a11,a12,a21,a22;\r
58                 a11=i_src.m00;\r
59                 a12=i_src.m01;\r
60                 a21=i_src.m10;\r
61                 a22=i_src.m11;\r
62                 double det=a11*a22-a12*a21;\r
63                 if(det==0){\r
64                         return false;\r
65                 }\r
66                 det=1/det;\r
67                 this.m00=a22*det;\r
68                 this.m01=-a12*det;\r
69                 this.m10=a21*det;\r
70                 this.m11=-a11*det;\r
71                 return true;\r
72         }       \r
73 }\r