OSDN Git Service

25b6ef7cf33e89679fa435c24f4679f71f196ec3
[nyartoolkit-and/nyartoolkit-and.git] / src / jp / nyatla / nyartoolkit / core / transmat / NyARTransMatResult.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.transmat;\r
32 \r
33 \r
34 import jp.nyatla.nyartoolkit.core.types.NyARDoublePoint3d;\r
35 import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
36 \r
37 /**\r
38  * NyARTransMat戻り値専用のNyARMat\r
39  * \r
40  */\r
41 public class NyARTransMatResult extends NyARDoubleMatrix34\r
42 {\r
43         public boolean has_value = false;\r
44         /**\r
45          * この関数は、0-PIの間で値を返します。\r
46          * @param o_out\r
47          */\r
48         public final void getZXYAngle(NyARDoublePoint3d o_out)\r
49         {\r
50                 double sina = this.m21;\r
51                 if (sina >= 1.0) {\r
52                         o_out.x = Math.PI / 2;\r
53                         o_out.y = 0;\r
54                         o_out.z = Math.atan2(-this.m10, this.m00);\r
55                 } else if (sina <= -1.0) {\r
56                         o_out.x = -Math.PI / 2;\r
57                         o_out.y = 0;\r
58                         o_out.z = Math.atan2(-this.m10, this.m00);\r
59                 } else {\r
60                         o_out.x = Math.asin(sina);\r
61                         o_out.z = Math.atan2(-this.m01, this.m11);\r
62                         o_out.y = Math.atan2(-this.m20, this.m22);\r
63                 }\r
64         }\r
65         public final void transformVertex(double i_x,double i_y,double i_z,NyARDoublePoint3d o_out)\r
66         {\r
67                 o_out.x=this.m00*i_x+this.m01*i_y+this.m02*i_z+this.m03;\r
68                 o_out.y=this.m10*i_x+this.m11*i_y+this.m12*i_z+this.m13;\r
69                 o_out.z=this.m20*i_x+this.m21*i_y+this.m22*i_z+this.m23;\r
70                 return;\r
71         }\r
72 }\r