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-2010 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.types;
\r
34 * このクラスは、整数型の2次元輪郭線を格納します。
\r
35 * 輪郭線は、2次元座標{@link NyARIntPoint2d}の集合です。
\r
37 public class NyARIntCoordinates
\r
40 public NyARIntPoint2d[] items;
\r
45 * 最大長さを指定して、有効要素数0のインスタンスを作ります。
\r
49 public NyARIntCoordinates(int i_length)
\r
51 this.items=NyARIntPoint2d.createArray(i_length);
\r
55 * この関数は2点を結ぶ直線を計算して、輪郭線を保存します。
\r
56 * 輪郭線は、Bresenhamのアルゴリズムで計算します。
\r
57 * 2点間の距離が、格納可能な最大長さ以下になるように注意してください。
\r
69 public boolean setLineCoordinates(int i_x0, int i_y0, int i_x1, int i_y1)
\r
71 NyARIntPoint2d[] ptr=this.items;
\r
73 int dx = (i_x1 > i_x0) ? i_x1 - i_x0 : i_x0 - i_x1;
\r
74 int dy = (i_y1 > i_y0) ? i_y1 - i_y0 : i_y0 - i_y1;
\r
75 int sx = (i_x1 > i_x0) ? 1 : -1;
\r
76 int sy = (i_y1 > i_y0) ? 1 : -1;
\r
82 if (dx >= ptr.length) {
\r
86 for (int i = 0; i <= dx; i++) {
\r
99 if (dy >= this.items.length) {
\r
103 for (int i = 0; i <= dy; i++) {
\r