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 version ARToolkit class library.
\r
11 * Copyright (C)2008 R.Iizuka
\r
13 * This program is free software; you can redistribute it and/or
\r
14 * modify it under the terms of the GNU General Public License
\r
15 * as published by the Free Software Foundation; either version 2
\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 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 framework; if not, write to the Free Software
\r
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
27 * For further information please contact.
\r
28 * http://nyatla.jp/nyatoolkit/
\r
29 * <airmail(at)ebony.plala.or.jp>
\r
32 package jp.nyatla.nyartoolkit.core;
\r
34 import jp.nyatla.nyartoolkit.NyARException;
\r
38 public class NyARVec
\r
42 public NyARVec(int i_clm)
\r
44 v = new double[i_clm];
\r
51 * i_clmサイズの列を格納できるように列サイズを変更します。 実行後、列の各値は不定になります。
\r
55 public void realloc(int i_clm)
\r
57 if (i_clm <= this.v.length) {
\r
61 v = new double[i_clm];
\r
71 public double[] getArray()
\r
82 public int arVecDisp() throws NyARException
\r
84 NyARException.trap("未チェックのパス");
\r
85 System.out.println(" === vector (" + clm + ") ===\n");// printf(" ===
\r
89 System.out.print(" |");// printf(" |");
\r
90 for (int c = 0; c < clm; c++) {// for( c = 0; c < v->clm; c++ ){
\r
91 System.out.print(" " + v[c]);// printf( " %10g", v->v[c] );
\r
93 System.out.println(" |");// printf(" |\n");
\r
94 System.out.println(" ===================");// printf("
\r
95 // ===================\n");
\r
100 * arVecInnerproduct関数の代替品
\r
105 * 演算開始列(よくわからないけどarVecTridiagonalizeの呼び出し元でなんかしてる)
\r
107 * @throws NyARException
\r
109 public double vecInnerproduct(NyARVec y, int i_start) throws NyARException
\r
111 NyARException.trap("この関数は動作確認できていません。");
\r
112 double result = 0.0;
\r
113 // double[] x_array=x.v;.getArray();
\r
114 // double[] y_array=y.getArray();
\r
116 if (this.clm != y.clm) {
\r
117 throw new NyARException();// exit();
\r
119 for (int i = i_start; i < this.clm; i++) {
\r
120 NyARException.trap("未チェックのパス");
\r
121 result += this.v[i] * y.v[i];// result += x->v[i] * y->v[i];
\r
127 * double arVecHousehold関数の代替品
\r
131 * 演算開始列(よくわからないけどarVecTridiagonalizeの呼び出し元でなんかしてる)
\r
133 * @throws NyARException
\r
135 public double vecHousehold(int i_start) throws NyARException
\r
137 NyARException.trap("この関数は動作確認できていません。");
\r
139 s = Math.sqrt(this.vecInnerproduct(this, i_start));
\r
140 // double[] x_array=x.getArray();
\r
142 NyARException.trap("未チェックのパス");
\r
143 if (this.v[i_start] < 0) {
\r
146 NyARException.trap("未チェックのパス");
\r
148 this.v[i_start] += s;// x->v[0] += s;
\r
149 t = 1 / Math.sqrt(this.v[i_start] * s);// t = 1 / sqrt(x->v[0] * s);
\r
151 for (int i = i_start; i < this.clm; i++) {
\r
152 NyARException.trap("未チェックのパス");
\r
153 this.v[i] *= t;// x->v[i] *= t;
\r
160 * 現在ラップしている配列を取り外して、新しい配列をラップします。
\r
165 public void setNewArray(double[] i_array, int i_clm)
\r