Vector(API)

提供: Eospedia
Vectorから転送)
移動: 案内検索

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座標リスト