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 version ARToolkit class library.
\r
11 * Copyright (C)2008 R.Iizuka
\r
13 * This program is free software; you can redistribute it and/or
\r
14 * modify it under the terms of the GNU General Public License
\r
15 * as published by the Free Software Foundation; either version 2
\r
16 * of the License, or (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 framework; if not, write to the Free Software
\r
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
27 * For further information please contact.
\r
28 * http://nyatla.jp/nyatoolkit/
\r
29 * <airmail(at)ebony.plala.or.jp>
\r
32 package jp.nyatla.nyartoolkit.core;
\r
35 * get_vertex関数を切り離すためのクラス
\r
38 final public class NyARVertexCounter
\r
40 public final int[] vertex = new int[10];// 6まで削れる
\r
42 public int number_of_vertex;
\r
44 private double thresh;
\r
46 private int[] x_coord;
\r
48 private int[] y_coord;
\r
50 public boolean getVertex(int[] i_x_coord, int[] i_y_coord, int st, int ed, double i_thresh)
\r
52 this.number_of_vertex = 0;
\r
53 this.thresh = i_thresh;
\r
54 this.x_coord = i_x_coord;
\r
55 this.y_coord = i_y_coord;
\r
56 return get_vertex(st, ed);
\r
60 * static int get_vertex( int x_coord[], int y_coord[], int st, int ed,double thresh, int vertex[], int *vnum) 関数の代替関数
\r
69 private boolean get_vertex(int st, int ed)
\r
71 //メモ:座標値は65536を超えなければint32で扱って大丈夫なので変更。
\r
72 //dmaxは4乗なのでやるとしてもint64じゃないとマズイ
\r
74 final int[] lx_coord = this.x_coord;
\r
75 final int[] ly_coord = this.y_coord;
\r
76 final int a = ly_coord[ed] - ly_coord[st];
\r
77 final int b = lx_coord[st] - lx_coord[ed];
\r
78 final int c = lx_coord[ed] * ly_coord[st] - ly_coord[ed] * lx_coord[st];
\r
80 for (int i = st + 1; i < ed; i++) {
\r
81 final double d = a * lx_coord[i] + b * ly_coord[i] + c;
\r
87 if (dmax / (double)(a * a + b * b) > thresh) {
\r
88 if (!get_vertex(st, v1)) {
\r
91 if (number_of_vertex > 5) {
\r
94 vertex[number_of_vertex] = v1;// vertex[(*vnum)] = v1;
\r
95 number_of_vertex++;// (*vnum)++;
\r
97 if (!get_vertex(v1, ed)) {
\r