1 package jp.nyatla.nyartoolkit.sandbox.x2;
\r
3 public final class NyARFixedFloatVertexCounter
\r
5 public final int[] vertex = new int[6];// 5まで削れる
\r
7 public int number_of_vertex;
\r
9 private long thresh_16f;
\r
11 private int[] x_coord;
\r
13 private int[] y_coord;
\r
15 public boolean getVertex(int[] i_x_coord, int[] i_y_coord, int st, int ed, long i_thresh)
\r
17 this.number_of_vertex = 0;
\r
18 this.thresh_16f = i_thresh;
\r
19 this.x_coord = i_x_coord;
\r
20 this.y_coord = i_y_coord;
\r
21 return get_vertex(st, ed);
\r
25 * static int get_vertex( int x_coord[], int y_coord[], int st, int ed,double thresh, int vertex[], int *vnum) 関数の代替関数
\r
34 private boolean get_vertex(int st, int ed)
\r
37 final int[] lx_coord = this.x_coord;
\r
38 final int[] ly_coord = this.y_coord;
\r
39 final int a = ly_coord[ed] - ly_coord[st];
\r
40 final int b = lx_coord[st] - lx_coord[ed];
\r
41 final int c = lx_coord[ed] * ly_coord[st] - ly_coord[ed] * lx_coord[st];
\r
43 for (int i = st + 1; i < ed; i++) {
\r
44 final long d = a * lx_coord[i] + b * ly_coord[i] + c;
\r
50 if ((dmax<<16) / (long)(a * a + b * b) > this.thresh_16f) {
\r
51 if (!get_vertex(st, v1)) {
\r
54 if (number_of_vertex > 5) {
\r
57 vertex[number_of_vertex] = v1;// vertex[(*vnum)] = v1;
\r
58 number_of_vertex++;// (*vnum)++;
\r
60 if (!get_vertex(v1, ed)) {
\r