「Vector(API)」の版間の差分

提供: Eospedia
移動: 案内検索
(ページの作成:「General/'''Vector'''は、ベクトル演算のためのAPI です。 == 構造体 == *ベクトル(float, int, double) typedef struct floatVector { unsigned long siz...」)
 
 
(同じ利用者による、間の6版が非表示)
行1: 行1:
General/'''Vector'''は、ベクトル演算のためのAPI です。
+
General/'''Vector'''は、ベクトル表現のためのAPI です。
  
 
== 構造体 ==
 
== 構造体 ==
*ベクトル(float, int, double)
+
ベクトル: float, int, double
 
  typedef struct floatVector {
 
  typedef struct floatVector {
 
  unsigned long size;
 
  unsigned long size;
行18: 行18:
 
  } doubleVector;
 
  } doubleVector;
 
   
 
   
size: ベクトルのサイズ(次元)
+
size: ベクトルのサイズ(次元)<br>
data: 実データ
+
data: 実データ
  
 
== API ==
 
== API ==
*初期化
+
===初期化===
 
  extern floatVector* floatVectorInit(floatVector* v, long size);
 
  extern floatVector* floatVectorInit(floatVector* v, long size);
 
  extern intVector* intVectorInit(intVector* v, long size);
 
  extern intVector* intVectorInit(intVector* v, long size);
 
  extern doubleVector* doubleVectorInit(doubleVector* v, long size);
 
  extern doubleVector* doubleVectorInit(doubleVector* v, long size);
  
*解放
+
===解放===
 
  extern floatVector* floatVectorFree(floatVector* v);
 
  extern floatVector* floatVectorFree(floatVector* v);
 
  extern intVector* intVectorFree(intVector* v);
 
  extern intVector* intVectorFree(intVector* v);
 
  extern doubleVector* doubleVectorFree(doubleVector* v);
 
  extern doubleVector* doubleVectorFree(doubleVector* v);
  
*加算
+
===加算===
 
  extern floatVector* floatVectorAdd(floatVector* v, floatVector* u, floatVector* w);
 
  extern floatVector* floatVectorAdd(floatVector* v, floatVector* u, floatVector* w);
 
  extern doubleVector* doubleVectorAdd(doubleVector* v, doubleVector* u, doubleVector* w);
 
  extern doubleVector* doubleVectorAdd(doubleVector* v, doubleVector* u, doubleVector* w);
  
*減算
+
===減算===
 
  extern floatVector* floatVectorMinus(floatVector* v, floatVector* u, floatVector* w);
 
  extern floatVector* floatVectorMinus(floatVector* v, floatVector* u, floatVector* w);
 
  extern doubleVector* doubleVectorMinus(doubleVector* v, doubleVector* u, doubleVector* w);
 
  extern doubleVector* doubleVectorMinus(doubleVector* v, doubleVector* u, doubleVector* w);
  
 
+
===内積===
 
  extern double floatVectorScalarProduct(floatVector* x, floatVector* y);
 
  extern double floatVectorScalarProduct(floatVector* x, floatVector* y);
 
  extern double doubleVectorScalarProduct(doubleVector* x, doubleVector* y);
 
  extern double doubleVectorScalarProduct(doubleVector* x, doubleVector* y);
 +
 +
===長さ===
 
  extern double lfloatVectorLength(floatVector* x);
 
  extern double lfloatVectorLength(floatVector* x);
 
  extern double ldoubleVectorLength(doubleVector* x);
 
  extern double ldoubleVectorLength(doubleVector* x);
  
 +
===スプライン曲線===
 +
====1次元スプライン曲線====
 +
=====微分値リスト作成=====
 
  extern void lVectorSplineTableMake(floatVector* x, floatVector* y, floatVector* z);
 
  extern void lVectorSplineTableMake(floatVector* x, floatVector* y, floatVector* z);
 
  extern void ldoubleVectorSplineTableMake(doubleVector* x, doubleVector* y, doubleVector* z);
 
  extern void ldoubleVectorSplineTableMake(doubleVector* x, doubleVector* y, doubleVector* z);
 +
<table border="1">
 +
<tr>
 +
<th>入力</th>
 +
<th>説明</th>
 +
</tr>
 +
<tr>
 +
<td>x[i]</td>
 +
<td>i番目までの距離の総和</td>
 +
</tr>
 +
<tr>
 +
<td>y[i]</td>
 +
<td>i番目のデータ</td>
 +
</tr>
 +
</table>
 +
<br>
  
 +
<table border="1">
 +
<tr>
 +
<th>出力</th>
 +
<th>説明</th>
 +
</tr>
 +
<tr>
 +
<td>z[i]</td>
 +
<td>i番目の微分値</td>
 +
</tr>
 +
</table>
 +
<br>
 +
 +
=====スプライン曲線の座標算出=====
 
  extern double lVectorSpline(double t, floatVector* x, floatVector* y, floatVector* z);
 
  extern double lVectorSpline(double t, floatVector* x, floatVector* y, floatVector* z);
 
  extern double ldoubleVectorSpline(double t, doubleVector* x, doubleVector* y, doubleVector* z);
 
  extern double ldoubleVectorSpline(double t, doubleVector* x, doubleVector* y, doubleVector* z);
  
 +
<table border="1">
 +
<tr>
 +
<th>入力</th>
 +
<th>説明</th>
 +
</tr>
 +
<tr>
 +
<td>t</td>
 +
<td>現在地の距離</td>
 +
</tr>
 +
<tr>
 +
<td>p</td>
 +
<td>距離リスト</td>
 +
</tr>
 +
<tr>
 +
<td>x</td>
 +
<td>微分値リスト</td>
 +
</tr>
 +
<tr>
 +
<td>y</td>
 +
<td>座標リスト</td>
 +
</tr>
 +
</table>
 +
<br>
 +
 +
<table border="1">
 +
<tr>
 +
<th>出力</th>
 +
<th>説明</th>
 +
</tr>
 +
<tr>
 +
<td>z</td>
 +
<td>補正後の座標リスト</td>
 +
</tr>
 +
</table>
 +
<br>
 +
 +
====2次元スプライン曲線====
 +
=====微分値リスト作成=====
 
  extern void lVectorSplineTable2DMake(floatVector* p, floatVector* x, floatVector* y, floatVector* a, floatVector* b);
 
  extern void lVectorSplineTable2DMake(floatVector* p, floatVector* x, floatVector* y, floatVector* a, floatVector* b);
 
  extern void ldoubleVectorSplineTable2DMake(doubleVector* p, doubleVector* x, doubleVector* y, doubleVector* a, doubleVector* b);
 
  extern void ldoubleVectorSplineTable2DMake(doubleVector* p, doubleVector* x, doubleVector* y, doubleVector* a, doubleVector* b);
 +
<table border="1">
 +
<tr>
 +
<th>入力</th>
 +
<th>説明</th>
 +
</tr>
 +
<tr>
 +
<td>x</td>
 +
<td>x座標リスト</td>
 +
</tr>
 +
<tr>
 +
<td>y</td>
 +
<td>y座標リスト</td>
 +
</tr>
 +
</table>
 +
<br>
 +
 +
<table border="1">
 +
<tr>
 +
<th>出力</th>
 +
<th>説明</th>
 +
</tr>
 +
<tr>
 +
<td>p[i]</td>
 +
<td>i番目までの距離の総和</td>
 +
</tr>
 +
<tr>
 +
<td>a[i]</td>
 +
<td>x座標のi番目での微分値</td>
 +
</tr>
 +
<tr>
 +
<td>b[i]</td>
 +
<td>y座標のi番目での微分値</td>
 +
</tr>
 +
</table>
 +
<br>
 +
 +
=====スプライン曲線の座標算出=====
 
  extern void lVectorSpline2D(double t, double* px, double* py, floatVector* p, floatVector* x, floatVector* y, floatVector* a, floatVector* b);
 
  extern void lVectorSpline2D(double t, double* px, double* py, floatVector* p, floatVector* x, floatVector* y, floatVector* a, floatVector* b);
 
  extern void ldoubleVectorSpline2D(double t, double* px, double* py, doubleVector* p, doubleVector* x, doubleVector* y, doubleVector* a, doubleVector* b);
 
  extern void ldoubleVectorSpline2D(double t, double* px, double* py, doubleVector* p, doubleVector* x, doubleVector* y, doubleVector* a, doubleVector* b);
 +
 +
<table border="1">
 +
<tr>
 +
<th>入力</th>
 +
<th>説明</th>
 +
</tr>
 +
<tr>
 +
<td>t</td>
 +
<td>現在地の距離</td>
 +
</tr>
 +
<tr>
 +
<td>p</td>
 +
<td>距離リスト</td>
 +
</tr>
 +
<tr>
 +
<td>x</td>
 +
<td>x座標リスト</td>
 +
</tr>
 +
<tr>
 +
<td>y</td>
 +
<td>y座標リスト</td>
 +
</tr>
 +
<tr>
 +
<td>a</td>
 +
<td>x座標の微分値リスト</td>
 +
</tr>
 +
<tr>
 +
<td>b</td>
 +
<td>y座標の微分値リスト</td>
 +
</tr>
 +
</table>
 +
<br>
 +
 +
<table border="1">
 +
<tr>
 +
<th>出力</th>
 +
<th>説明</th>
 +
</tr>
 +
<tr>
 +
<td>px</td>
 +
<td>補正後のx座標リスト</td>
 +
</tr>
 +
<tr>
 +
<td>py</td>
 +
<td>補正後のy座標リスト</td>
 +
</tr>
 +
</table>
 +
<br>

2014年5月22日 (木) 08:50時点における最新版

General/Vectorは、ベクトル表現のためのAPI です。

構造体

ベクトル: float, int, double

typedef struct floatVector {
	unsigned long size;
	float*        data;
} floatVector;

typedef struct intVector {
	unsigned long size;
	int*        data;
} intVector;

typedef struct doubleVector {
	unsigned long size;
	double*        data;
} doubleVector;

size: ベクトルのサイズ(次元)
data: 実データ

API

初期化

extern floatVector* floatVectorInit(floatVector* v, long size);
extern intVector* intVectorInit(intVector* v, long size);
extern doubleVector* doubleVectorInit(doubleVector* v, long size);

解放

extern floatVector* floatVectorFree(floatVector* v);
extern intVector* intVectorFree(intVector* v);
extern doubleVector* doubleVectorFree(doubleVector* v);

加算

extern floatVector* floatVectorAdd(floatVector* v, floatVector* u, floatVector* w);
extern doubleVector* doubleVectorAdd(doubleVector* v, doubleVector* u, doubleVector* w);

減算

extern floatVector* floatVectorMinus(floatVector* v, floatVector* u, floatVector* w);
extern doubleVector* doubleVectorMinus(doubleVector* v, doubleVector* u, doubleVector* w);

内積

extern double floatVectorScalarProduct(floatVector* x, floatVector* y);
extern double doubleVectorScalarProduct(doubleVector* x, doubleVector* y);

長さ

extern double lfloatVectorLength(floatVector* x);
extern double ldoubleVectorLength(doubleVector* x);

スプライン曲線

1次元スプライン曲線

微分値リスト作成
extern void lVectorSplineTableMake(floatVector* x, floatVector* y, floatVector* z);
extern void ldoubleVectorSplineTableMake(doubleVector* x, doubleVector* y, doubleVector* z);
入力 説明
x[i] i番目までの距離の総和
y[i] i番目のデータ


出力 説明
z[i] i番目の微分値


スプライン曲線の座標算出
extern double lVectorSpline(double t, floatVector* x, floatVector* y, floatVector* z);
extern double ldoubleVectorSpline(double t, doubleVector* x, doubleVector* y, doubleVector* z);
入力 説明
t 現在地の距離
p 距離リスト
x 微分値リスト
y 座標リスト


出力 説明
z 補正後の座標リスト


2次元スプライン曲線

微分値リスト作成
extern void lVectorSplineTable2DMake(floatVector* p, floatVector* x, floatVector* y, floatVector* a, floatVector* b);
extern void ldoubleVectorSplineTable2DMake(doubleVector* p, doubleVector* x, doubleVector* y, doubleVector* a, doubleVector* b);
入力 説明
x x座標リスト
y y座標リスト


出力 説明
p[i] i番目までの距離の総和
a[i] x座標のi番目での微分値
b[i] y座標のi番目での微分値


スプライン曲線の座標算出
extern void lVectorSpline2D(double t, double* px, double* py, floatVector* p, floatVector* x, floatVector* y, floatVector* a, floatVector* b);
extern void ldoubleVectorSpline2D(double t, double* px, double* py, doubleVector* p, doubleVector* x, doubleVector* y, doubleVector* a, doubleVector* b);
入力 説明
t 現在地の距離
p 距離リスト
x x座標リスト
y y座標リスト
a x座標の微分値リスト
b y座標の微分値リスト


出力 説明
px 補正後のx座標リスト
py 補正後のy座標リスト