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
37 * 2次元の浮動小数点方の点を格納します。
\r
39 public class NyARDoublePoint2d
\r
48 public static NyARDoublePoint2d[] createArray(int i_number)
\r
50 NyARDoublePoint2d[] ret=new NyARDoublePoint2d[i_number];
\r
51 for(int i=0;i<i_number;i++)
\r
53 ret[i]=new NyARDoublePoint2d();
\r
57 public static NyARDoublePoint2d[][] create2dArray(int i_length_x,int i_length_y)
\r
59 NyARDoublePoint2d[][] ret=new NyARDoublePoint2d[i_length_y][i_length_x];
\r
60 for(int i=0;i<i_length_y;i++)
\r
62 for(int i2=0;i2<i_length_x;i2++)
\r
64 ret[i][i2]=new NyARDoublePoint2d();
\r
70 * p1->p2と、p2->p3の直線の外積を計算します。
\r
76 public final static double crossProduct3Point(NyARDoublePoint2d p1,NyARDoublePoint2d p2,NyARDoublePoint2d p3)
\r
78 return (p2.x-p1.x)*(p3.y-p2.y)-(p2.y-p1.y)*(p3.x-p2.x);
\r
81 * p1->p2と、p2->p3の直線の外積を計算します。
\r
87 public final static double crossProduct3Point(NyARDoublePoint2d p1,NyARDoublePoint2d p2,double p3_x,double p3_y)
\r
89 return (p2.x-p1.x)*(p3_y-p2.y)-(p2.y-p1.y)*(p3_x-p2.x);
\r
97 * @param i_number_of_data
\r
101 public final static void makeCenter(NyARDoublePoint2d[] i_points,int i_number_of_data,NyARDoublePoint2d o_out)
\r
105 for(int i=i_number_of_data-1;i>=0;i--)
\r
110 o_out.x=x/i_number_of_data;
\r
111 o_out.x=y/i_number_of_data;
\r
114 * {@link #makeCenter}の出力型違いの関数です。
\r
116 * @param i_number_of_data
\r
119 public final static void makeCenter(NyARDoublePoint2d[] i_points,int i_number_of_data,NyARIntPoint2d o_out)
\r
123 for(int i=i_number_of_data-1;i>=0;i--)
\r
128 o_out.x=(int)(lx/i_number_of_data);
\r
129 o_out.y=(int)(ly/i_number_of_data);
\r
135 public NyARDoublePoint2d()
\r
142 * i_srcの値をthisへセットします。
\r
145 public NyARDoublePoint2d(double i_x,double i_y)
\r
152 * i_srcの値をthisへセットします。
\r
155 public NyARDoublePoint2d(NyARDoublePoint2d i_src)
\r
162 * i_srcの値をthisへセットします。
\r
165 public NyARDoublePoint2d(NyARIntPoint2d i_src)
\r
167 this.x=(double)i_src.x;
\r
168 this.y=(double)i_src.y;
\r
172 * p2-p1間の距離の二乗値を計算します。
\r
177 public final double sqDist(NyARDoublePoint2d i_p1)
\r
184 public final double sqDist(NyARIntPoint2d i_p1)
\r
192 * i_srcの値をthisへセットします。
\r
195 public final void setValue(NyARDoublePoint2d i_src)
\r
202 * i_srcの値をthisへセットします。
\r
205 public final void setValue(NyARIntPoint2d i_src)
\r
207 this.x=(double)i_src.x;
\r
208 this.y=(double)i_src.y;
\r
211 public final void setValue(double x,double y)
\r