2 * PROJECT: NyARToolkit
\r
3 * --------------------------------------------------------------------------------
\r
4 * This work is based on the original ARToolKit developed by
\r
7 * HITLab, University of Washington, Seattle
\r
8 * http://www.hitl.washington.edu/artoolkit/
\r
10 * The NyARToolkit is Java edition ARToolKit class library.
\r
11 * Copyright (C)2008-2009 Ryo Iizuka
\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
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
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
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
31 package jp.nyatla.nyartoolkit.core.squaredetect;
\r
34 * get_vertex関数を切り離すためのクラス
\r
37 final public class NyARVertexCounter
\r
39 public final int[] vertex = new int[10];// 6まで削れる
\r
41 public int number_of_vertex;
\r
43 private double thresh;
\r
45 private int[] x_coord;
\r
47 private int[] y_coord;
\r
49 public boolean getVertex(int[] i_x_coord, int[] i_y_coord, int st, int ed, double i_thresh)
\r
51 this.number_of_vertex = 0;
\r
52 this.thresh = i_thresh;
\r
53 this.x_coord = i_x_coord;
\r
54 this.y_coord = i_y_coord;
\r
55 return get_vertex(st, ed);
\r
59 * static int get_vertex( int x_coord[], int y_coord[], int st, int ed,double thresh, int vertex[], int *vnum) 関数の代替関数
\r
68 private boolean get_vertex(int st, int ed)
\r
70 //メモ:座標値は65536を超えなければint32で扱って大丈夫なので変更。
\r
71 //dmaxは4乗なのでやるとしてもint64じゃないとマズイ
\r
73 final int[] lx_coord = this.x_coord;
\r
74 final int[] ly_coord = this.y_coord;
\r
75 final int a = ly_coord[ed] - ly_coord[st];
\r
76 final int b = lx_coord[st] - lx_coord[ed];
\r
77 final int c = lx_coord[ed] * ly_coord[st] - ly_coord[ed] * lx_coord[st];
\r
79 for (int i = st + 1; i < ed; i++) {
\r
80 final double d = a * lx_coord[i] + b * ly_coord[i] + c;
\r
86 if (dmax / (double)(a * a + b * b) > thresh) {
\r
87 if (!get_vertex(st, v1)) {
\r
90 if (number_of_vertex > 5) {
\r
93 vertex[number_of_vertex] = v1;// vertex[(*vnum)] = v1;
\r
94 number_of_vertex++;// (*vnum)++;
\r
96 if (!get_vertex(v1, ed)) {
\r