OSDN Git Service

[TAG]NyARToolkit/2.5.0
[nyartoolkit-and/nyartoolkit-and.git] / tags / 2.5.0 / src / jp / nyatla / nyartoolkit / core / types / NyARDoublePoint2d.java
diff --git a/tags/2.5.0/src/jp/nyatla/nyartoolkit/core/types/NyARDoublePoint2d.java b/tags/2.5.0/src/jp/nyatla/nyartoolkit/core/types/NyARDoublePoint2d.java
new file mode 100644 (file)
index 0000000..ad86ff1
--- /dev/null
@@ -0,0 +1,108 @@
+/* \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.types;\r
+\r
+\r
+public class NyARDoublePoint2d\r
+{\r
+       public double x;\r
+       public double y;\r
+       /**\r
+        * 配列ファクトリ\r
+        * @param i_number\r
+        * @return\r
+        */\r
+       public static NyARDoublePoint2d[] createArray(int i_number)\r
+       {\r
+               NyARDoublePoint2d[] ret=new NyARDoublePoint2d[i_number];\r
+               for(int i=0;i<i_number;i++)\r
+               {\r
+                       ret[i]=new NyARDoublePoint2d();\r
+               }\r
+               return ret;\r
+       }\r
+       public static NyARDoublePoint2d[][] create2dArray(int i_length_x,int i_length_y)\r
+       {\r
+               NyARDoublePoint2d[][] ret=new NyARDoublePoint2d[i_length_y][i_length_x];\r
+               for(int i=0;i<i_length_y;i++)\r
+               {\r
+                       for(int i2=0;i2<i_length_x;i2++)\r
+                       {\r
+                               ret[i][i2]=new NyARDoublePoint2d();\r
+                       }\r
+               }\r
+               return ret;\r
+       }\r
+       public NyARDoublePoint2d()\r
+       {\r
+               this.x=0;\r
+               this.y=0;\r
+               return;\r
+       }       \r
+       public NyARDoublePoint2d(double i_x,double i_y)\r
+       {\r
+               this.x=i_x;\r
+               this.y=i_y;\r
+               return;\r
+       }\r
+       public NyARDoublePoint2d(NyARDoublePoint2d i_src)\r
+       {\r
+               this.x=i_src.x;\r
+               this.y=i_src.y;\r
+               return;\r
+       }\r
+       public NyARDoublePoint2d(NyARIntPoint2d i_src)\r
+       {\r
+               this.x=(double)i_src.x;\r
+               this.y=(double)i_src.y;\r
+               return;\r
+       }\r
+       public void setValue(NyARDoublePoint2d i_src)\r
+       {\r
+               this.x=i_src.x;\r
+               this.y=i_src.y;\r
+               return;\r
+       }\r
+       public void setValue(NyARIntPoint2d i_src)\r
+       {\r
+               this.x=(double)i_src.x;\r
+               this.y=(double)i_src.y;\r
+               return;\r
+       }\r
+       /**\r
+        * 格納値をベクトルとして、距離を返します。\r
+        * @return\r
+        */\r
+       public final double dist()\r
+       {\r
+               return Math.sqrt(this.x*this.x+this.y+this.y);\r
+       }\r
+}\r