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
\r
14 * modify it under the terms of the GNU Lesser General Public License
\r
15 * as published by the Free Software Foundation; either version 3
\r
16 * of the License, or (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 Lesser General Public License for more details
\r
23 * You should have received a copy of the GNU Lesser General Public
\r
24 * License 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 public class NyARVec
\r
41 public NyARVec(int i_clm)
\r
43 v = new double[i_clm];
\r
50 * i_clmサイズの列を格納できるように列サイズを変更します。 実行後、列の各値は不定になります。
\r
54 public void realloc(int i_clm)
\r
56 if (i_clm <= this.v.length) {
\r
60 v = new double[i_clm];
\r
70 public double[] getArray()
\r
81 public int arVecDisp() throws NyARException
\r
83 NyARException.trap("未チェックのパス");
\r
84 System.out.println(" === vector (" + clm + ") ===\n");// printf(" ===
\r
88 System.out.print(" |");// printf(" |");
\r
89 for (int c = 0; c < clm; c++) {// for( c = 0; c < v->clm; c++ ){
\r
90 System.out.print(" " + v[c]);// printf( " %10g", v->v[c] );
\r
92 System.out.println(" |");// printf(" |\n");
\r
93 System.out.println(" ===================");// printf("
\r
94 // ===================\n");
\r
99 * arVecInnerproduct関数の代替品
\r
104 * 演算開始列(よくわからないけどarVecTridiagonalizeの呼び出し元でなんかしてる)
\r
106 * @throws NyARException
\r
108 public double vecInnerproduct(NyARVec y, int i_start) throws NyARException
\r
110 NyARException.trap("この関数は動作確認できていません。");
\r
111 double result = 0.0;
\r
112 // double[] x_array=x.v;.getArray();
\r
113 // double[] y_array=y.getArray();
\r
115 if (this.clm != y.clm) {
\r
116 throw new NyARException();// exit();
\r
118 for (int i = i_start; i < this.clm; i++) {
\r
119 NyARException.trap("未チェックのパス");
\r
120 result += this.v[i] * y.v[i];// result += x->v[i] * y->v[i];
\r
126 * double arVecHousehold関数の代替品
\r
130 * 演算開始列(よくわからないけどarVecTridiagonalizeの呼び出し元でなんかしてる)
\r
132 * @throws NyARException
\r
134 public double vecHousehold(int i_start) throws NyARException
\r
136 NyARException.trap("この関数は動作確認できていません。");
\r
138 s = Math.sqrt(this.vecInnerproduct(this, i_start));
\r
139 // double[] x_array=x.getArray();
\r
141 NyARException.trap("未チェックのパス");
\r
142 if (this.v[i_start] < 0) {
\r
145 NyARException.trap("未チェックのパス");
\r
147 this.v[i_start] += s;// x->v[0] += s;
\r
148 t = 1 / Math.sqrt(this.v[i_start] * s);// t = 1 / sqrt(x->v[0] * s);
\r
150 for (int i = i_start; i < this.clm; i++) {
\r
151 NyARException.trap("未チェックのパス");
\r
152 this.v[i] *= t;// x->v[i] *= t;
\r
159 * 現在ラップしている配列を取り外して、新しい配列をラップします。
\r
164 public void setNewArray(double[] i_array, int i_clm)
\r