OSDN Git Service

[TAG]NyARToolkit/2.5.0
[nyartoolkit-and/nyartoolkit-and.git] / tags / 2.5.0 / src / jp / nyatla / nyartoolkit / core / transmat / NyARTransMatResult.java
diff --git a/tags/2.5.0/src/jp/nyatla/nyartoolkit/core/transmat/NyARTransMatResult.java b/tags/2.5.0/src/jp/nyatla/nyartoolkit/core/transmat/NyARTransMatResult.java
new file mode 100644 (file)
index 0000000..18838e3
--- /dev/null
@@ -0,0 +1,80 @@
+/* \r
+ * PROJECT: NyARToolkit\r
+ * --------------------------------------------------------------------------------\r
+ * This work is based on the original ARToolKit developed by\r
+ *   Hirokazu Kato\r
+ *   Mark Billinghurst\r
+ *   HITLab, University of Washington, Seattle\r
+ * http://www.hitl.washington.edu/artoolkit/\r
+ *\r
+ * The NyARToolkit is Java edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
+ *\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ * \r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
+ * \r
+ * For further information please contact.\r
+ *     http://nyatla.jp/nyatoolkit/\r
+ *     <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.core.transmat;\r
+\r
+\r
+import jp.nyatla.nyartoolkit.core.types.NyARDoublePoint3d;\r
+import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
+\r
+/**\r
+ * NyARTransMat戻り値専用のNyARMat\r
+ * \r
+ */\r
+public class NyARTransMatResult extends NyARDoubleMatrix34\r
+{\r
+       /**\r
+        * エラーレート。この値はINyARTransMatの派生クラスが使います。\r
+        */\r
+       public double error;    \r
+       public boolean has_value = false;\r
+       /**\r
+        * この関数は、0-PIの間で値を返します。\r
+        * @param o_out\r
+        */\r
+       public final void getZXYAngle(NyARDoublePoint3d o_out)\r
+       {\r
+               double sina = this.m21;\r
+               if (sina >= 1.0) {\r
+                       o_out.x = Math.PI / 2;\r
+                       o_out.y = 0;\r
+                       o_out.z = Math.atan2(-this.m10, this.m00);\r
+               } else if (sina <= -1.0) {\r
+                       o_out.x = -Math.PI / 2;\r
+                       o_out.y = 0;\r
+                       o_out.z = Math.atan2(-this.m10, this.m00);\r
+               } else {\r
+                       o_out.x = Math.asin(sina);\r
+                       o_out.z = Math.atan2(-this.m01, this.m11);\r
+                       o_out.y = Math.atan2(-this.m20, this.m22);\r
+               }\r
+       }\r
+       public final void transformVertex(double i_x,double i_y,double i_z,NyARDoublePoint3d o_out)\r
+       {\r
+               o_out.x=this.m00*i_x+this.m01*i_y+this.m02*i_z+this.m03;\r
+               o_out.y=this.m10*i_x+this.m11*i_y+this.m12*i_z+this.m13;\r
+               o_out.z=this.m20*i_x+this.m21*i_y+this.m22*i_z+this.m23;\r
+               return;\r
+       }\r
+       public final void transformVertex(NyARDoublePoint3d i_in,NyARDoublePoint3d o_out)\r
+       {\r
+               transformVertex(i_in.x,i_in.y,i_in.z,o_out);\r
+       }\r
+}\r