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;
\r
33 import jp.nyatla.nyartoolkit.NyARException;
\r
37 * このクラスは、ARToolKit由来のベクトル値計算関数を提供します。
\r
39 * このクラスは、今後統合・削除する可能性があります。
\r
42 public class NyARVec
\r
52 * 列数を指定して、インスタンスを生成します。
\r
56 public NyARVec(int i_clm)
\r
58 v = new double[i_clm];
\r
63 * ベクトルのバッファサイズを、i_clmに十分になるように変更します。
\r
68 public void realloc(int i_clm)
\r
70 if (i_clm <= this.v.length) {
\r
74 v = new double[i_clm];
\r
90 * ベクトル値を格納した配列の参照値を返します。
\r
94 public double[] getArray()
\r
100 * arVecInnerproduct関数の同等品です。
\r
101 * この関数は動作チェックをしておらず、機能しません。
\r
106 * 演算開始列(よくわからないけどarVecTridiagonalizeの呼び出し元でなんかしてる)
\r
109 * @throws NyARException
\r
111 public double vecInnerproduct(NyARVec y, int i_start) throws NyARException
\r
113 NyARException.trap("この関数は動作確認できていません。");
\r
114 double result = 0.0;
\r
115 // double[] x_array=x.v;.getArray();
\r
116 // double[] y_array=y.getArray();
\r
118 if (this.clm != y.clm) {
\r
119 throw new NyARException();// exit();
\r
121 for (int i = i_start; i < this.clm; i++) {
\r
122 NyARException.trap("未チェックのパス");
\r
123 result += this.v[i] * y.v[i];// result += x->v[i] * y->v[i];
\r
129 * arVecHousehold関数の同等品です。
\r
132 * 演算開始列(よくわからないけどarVecTridiagonalizeの呼び出し元でなんかしてる)
\r
135 * @throws NyARException
\r
137 public double vecHousehold(int i_start) throws NyARException
\r
139 NyARException.trap("この関数は動作確認できていません。");
\r
141 s = Math.sqrt(this.vecInnerproduct(this, i_start));
\r
142 // double[] x_array=x.getArray();
\r
144 NyARException.trap("未チェックのパス");
\r
145 if (this.v[i_start] < 0) {
\r
148 NyARException.trap("未チェックのパス");
\r
150 this.v[i_start] += s;// x->v[0] += s;
\r
151 t = 1 / Math.sqrt(this.v[i_start] * s);// t = 1 / sqrt(x->v[0] * s);
\r
153 for (int i = i_start; i < this.clm; i++) {
\r
154 NyARException.trap("未チェックのパス");
\r
155 this.v[i] *= t;// x->v[i] *= t;
\r
162 * 現在ラップしている配列を取り外して、新しい配列と、列数をセットします。
\r
164 * 新しく設定する配列です。この配列は、thisが所有します。
\r
168 public void setNewArray(double[] i_array, int i_clm)
\r