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.types;
\r
36 * 2次元の浮動小数点座標を格納します。
\r
38 public class NyARDoublePoint2d
\r
45 * この関数は、オブジェクトの一次元配列を作ります。
\r
51 public static NyARDoublePoint2d[] createArray(int i_number)
\r
53 NyARDoublePoint2d[] ret=new NyARDoublePoint2d[i_number];
\r
54 for(int i=0;i<i_number;i++)
\r
56 ret[i]=new NyARDoublePoint2d();
\r
61 * この関数は、オブジェクトの二次元配列を作ります。
\r
69 public static NyARDoublePoint2d[][] create2dArray(int i_length_x,int i_length_y)
\r
71 NyARDoublePoint2d[][] ret=new NyARDoublePoint2d[i_length_y][i_length_x];
\r
72 for(int i=0;i<i_length_y;i++)
\r
74 for(int i2=0;i2<i_length_x;i2++)
\r
76 ret[i][i2]=new NyARDoublePoint2d();
\r
82 * この関数は、3点で定義される直線から、外積を計算します。
\r
83 * 外積は、p1->p2と、p2->p3で定義する直線の外積です。
\r
93 public final static double crossProduct3Point(NyARDoublePoint2d p1,NyARDoublePoint2d p2,NyARDoublePoint2d p3)
\r
95 return (p2.x-p1.x)*(p3.y-p2.y)-(p2.y-p1.y)*(p3.x-p2.x);
\r
98 * この関数は、3点で定義される直線から、外積を計算します。
\r
99 * 外積は、p1->p2と、p2->p3で定義する直線の外積です。
\r
111 public final static double crossProduct3Point(NyARDoublePoint2d p1,NyARDoublePoint2d p2,double p3_x,double p3_y)
\r
113 return (p2.x-p1.x)*(p3_y-p2.y)-(p2.y-p1.y)*(p3_x-p2.x);
\r
116 * この関数は、頂点集合から、中央値(Σp[n]/n)を求めます。
\r
119 * @param i_number_of_data
\r
122 * 中央値を受け取るオブジェクトです。
\r
124 public final static void makeCenter(NyARDoublePoint2d[] i_points,int i_number_of_data,NyARDoublePoint2d o_out)
\r
128 for(int i=i_number_of_data-1;i>=0;i--)
\r
133 o_out.x=x/i_number_of_data;
\r
134 o_out.x=y/i_number_of_data;
\r
137 * この関数は、頂点集合から、中央値(Σp[n]/n)を求めます。
\r
140 * @param i_number_of_data
\r
143 * 中央値を受け取るオブジェクトです。
\r
145 public final static void makeCenter(NyARDoublePoint2d[] i_points,int i_number_of_data,NyARIntPoint2d o_out)
\r
149 for(int i=i_number_of_data-1;i>=0;i--)
\r
154 o_out.x=(int)(lx/i_number_of_data);
\r
155 o_out.y=(int)(ly/i_number_of_data);
\r
159 * 初期値を格納したインスタンスを生成します。
\r
161 public NyARDoublePoint2d()
\r
169 * 初期値を指定してインスタンスを生成します。
\r
175 public NyARDoublePoint2d(double i_x,double i_y)
\r
183 * i_srcの値で初期化したインスタンスを生成します。
\r
187 public NyARDoublePoint2d(NyARDoublePoint2d i_src)
\r
195 * i_srcの値で初期化したインスタンスを生成します。
\r
199 public NyARDoublePoint2d(NyARIntPoint2d i_src)
\r
201 this.x=(double)i_src.x;
\r
202 this.y=(double)i_src.y;
\r
206 * この関数は、インスタンスの座標と、指定点との距離の2乗値を返します。
\r
212 public final double sqDist(NyARDoublePoint2d i_p1)
\r
220 * この関数は、インスタンスの座標と、指定点との距離の2乗値を返します。
\r
226 public final double sqDist(NyARIntPoint2d i_p1)
\r
234 * この関数は、オブジェクトからインスタンスに値をセットします。
\r
238 public final void setValue(NyARDoublePoint2d i_src)
\r
245 * この関数は、オブジェクトからインスタンスに値をセットします。
\r
249 public final void setValue(NyARIntPoint2d i_src)
\r
251 this.x=(double)i_src.x;
\r
252 this.y=(double)i_src.y;
\r
256 * この関数は、インスタンスに値をセットします。
\r
258 * {@link #x}にセットする値
\r
260 * {@link #y}にセットする値
\r
262 public final void setValue(double i_x,double i_y)
\r