* 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\r
- * modify it under the terms of the GNU Lesser General Public License\r
- * as published by the Free Software Foundation; either version 3\r
- * of the License, or (at your option) any later version.\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 Lesser General Public License for more details\r
- * \r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this program. If not, see <http://www.gnu.org/licenses/>.\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
\r
private int[] y_coord;\r
\r
- public boolean getVertex(int[] i_x_coord, int[] i_y_coord, int st, int ed, double i_thresh)\r
+ public boolean getVertex(int[] i_x_coord, int[] i_y_coord,int i_coord_len,int st, int ed, double i_thresh)\r
{\r
this.number_of_vertex = 0;\r
this.thresh = i_thresh;\r
this.x_coord = i_x_coord;\r
this.y_coord = i_y_coord;\r
- return get_vertex(st, ed);\r
+ return get_vertex(st, ed,i_coord_len);\r
}\r
\r
/**\r
* @param thresh\r
* @return\r
*/\r
- private boolean get_vertex(int st, int ed)\r
+ private boolean get_vertex(int st, int ed,int i_coord_len)\r
{\r
//メモ:座標値は65536を超えなければint32で扱って大丈夫なので変更。\r
//dmaxは4乗なのでやるとしてもint64じゃないとマズイ\r
final int b = lx_coord[st] - lx_coord[ed];\r
final int c = lx_coord[ed] * ly_coord[st] - ly_coord[ed] * lx_coord[st];\r
double dmax = 0;\r
- for (int i = st + 1; i < ed; i++) {\r
- final double d = a * lx_coord[i] + b * ly_coord[i] + c;\r
- if (d * d > dmax) {\r
- dmax = d * d;\r
- v1 = i;\r
+ if(st<ed){\r
+ //stとedが1区間\r
+ for (int i = st + 1; i < ed; i++) {\r
+ final double d = a * lx_coord[i] + b * ly_coord[i] + c;\r
+ if (d * d > dmax) {\r
+ dmax = d * d;\r
+ v1 = i;\r
+ }\r
+ }\r
+ }else{\r
+ //stとedが2区間\r
+ for (int i = st + 1; i < i_coord_len; i++) {\r
+ final double d = a * lx_coord[i] + b * ly_coord[i] + c;\r
+ if (d * d > dmax) {\r
+ dmax = d * d;\r
+ v1 = i;\r
+ }\r
+ }\r
+ for (int i = 0; i < ed; i++) {\r
+ final double d = a * lx_coord[i] + b * ly_coord[i] + c;\r
+ if (d * d > dmax) {\r
+ dmax = d * d;\r
+ v1 = i;\r
+ }\r
}\r
}\r
+\r
+ \r
if (dmax / (double)(a * a + b * b) > thresh) {\r
- if (!get_vertex(st, v1)) {\r
+ if (!get_vertex(st, v1,i_coord_len)) {\r
return false;\r
}\r
if (number_of_vertex > 5) {\r
vertex[number_of_vertex] = v1;// vertex[(*vnum)] = v1;\r
number_of_vertex++;// (*vnum)++;\r
\r
- if (!get_vertex(v1, ed)) {\r
+ if (!get_vertex(v1, ed,i_coord_len)) {\r
return false;\r
}\r
}\r