慣性航法で用いられる座標変換をプログラムにしました。ECI座標の初期位置を設定した後、ECI,ECEF,NED,機体座標系の変換を行います。行列計算の方法や値の設定などは、ヘッダーファイル内の記述を見れば分かると思います。 また計算結果はTeratermで確認する事が出来ます。 (行列を見る場合はtoString関数、ベクトルを見る場合はtoString_V関数を使用します)
Vector/Vector.h@0:6a28eb668082, 2019-01-30 (annotated)
- Committer:
- Joeatsumi
- Date:
- Wed Jan 30 11:39:03 2019 +0000
- Revision:
- 0:6a28eb668082
Direction cosine matrix and it's calculation.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Joeatsumi | 0:6a28eb668082 | 1 | #pragma once |
Joeatsumi | 0:6a28eb668082 | 2 | #include "mbed.h" |
Joeatsumi | 0:6a28eb668082 | 3 | |
Joeatsumi | 0:6a28eb668082 | 4 | class Matrix; |
Joeatsumi | 0:6a28eb668082 | 5 | |
Joeatsumi | 0:6a28eb668082 | 6 | class Vector { |
Joeatsumi | 0:6a28eb668082 | 7 | public: |
Joeatsumi | 0:6a28eb668082 | 8 | Vector(int dim); |
Joeatsumi | 0:6a28eb668082 | 9 | ~Vector(); |
Joeatsumi | 0:6a28eb668082 | 10 | Vector(const Vector& v); |
Joeatsumi | 0:6a28eb668082 | 11 | |
Joeatsumi | 0:6a28eb668082 | 12 | Vector& operator=(const Vector& v); |
Joeatsumi | 0:6a28eb668082 | 13 | Vector operator+(); |
Joeatsumi | 0:6a28eb668082 | 14 | Vector operator-(); |
Joeatsumi | 0:6a28eb668082 | 15 | Vector& operator*=(float c); |
Joeatsumi | 0:6a28eb668082 | 16 | Vector& operator/=(float c); |
Joeatsumi | 0:6a28eb668082 | 17 | Vector& operator+=(const Vector& v); |
Joeatsumi | 0:6a28eb668082 | 18 | Vector& operator-=(const Vector& v); |
Joeatsumi | 0:6a28eb668082 | 19 | |
Joeatsumi | 0:6a28eb668082 | 20 | void SetComp(int dimNo, float val); |
Joeatsumi | 0:6a28eb668082 | 21 | void SetComps(float* vals); |
Joeatsumi | 0:6a28eb668082 | 22 | float GetNorm() const; |
Joeatsumi | 0:6a28eb668082 | 23 | Vector Normalize() const; |
Joeatsumi | 0:6a28eb668082 | 24 | Vector GetParaCompTo(Vector v); |
Joeatsumi | 0:6a28eb668082 | 25 | Vector GetPerpCompTo(Vector v); |
Joeatsumi | 0:6a28eb668082 | 26 | |
Joeatsumi | 0:6a28eb668082 | 27 | inline int GetDim() const { |
Joeatsumi | 0:6a28eb668082 | 28 | return dim; |
Joeatsumi | 0:6a28eb668082 | 29 | } |
Joeatsumi | 0:6a28eb668082 | 30 | |
Joeatsumi | 0:6a28eb668082 | 31 | inline const float* GetpComponents() const { |
Joeatsumi | 0:6a28eb668082 | 32 | return (const float*)components; |
Joeatsumi | 0:6a28eb668082 | 33 | } |
Joeatsumi | 0:6a28eb668082 | 34 | |
Joeatsumi | 0:6a28eb668082 | 35 | inline float GetComp(int dimNo) const { |
Joeatsumi | 0:6a28eb668082 | 36 | if (dimNo > dim) error("Index Out of Bounds Error !!"); |
Joeatsumi | 0:6a28eb668082 | 37 | return components[dimNo-1]; |
Joeatsumi | 0:6a28eb668082 | 38 | } |
Joeatsumi | 0:6a28eb668082 | 39 | |
Joeatsumi | 0:6a28eb668082 | 40 | void CleanUp(); |
Joeatsumi | 0:6a28eb668082 | 41 | |
Joeatsumi | 0:6a28eb668082 | 42 | private: |
Joeatsumi | 0:6a28eb668082 | 43 | int dim; |
Joeatsumi | 0:6a28eb668082 | 44 | float* components; |
Joeatsumi | 0:6a28eb668082 | 45 | |
Joeatsumi | 0:6a28eb668082 | 46 | Vector& operator*=(const Matrix& m); |
Joeatsumi | 0:6a28eb668082 | 47 | Vector& operator*=(const Vector& m); |
Joeatsumi | 0:6a28eb668082 | 48 | }; |
Joeatsumi | 0:6a28eb668082 | 49 | |
Joeatsumi | 0:6a28eb668082 | 50 | Vector operator+(const Vector& lhv, const Vector& rhv); |
Joeatsumi | 0:6a28eb668082 | 51 | Vector operator-(const Vector& lhv, const Vector& rhv); |
Joeatsumi | 0:6a28eb668082 | 52 | Vector Cross(const Vector& lhv, const Vector& rhv); |
Joeatsumi | 0:6a28eb668082 | 53 | Vector operator*(const float c, const Vector& rhv); |
Joeatsumi | 0:6a28eb668082 | 54 | Vector operator*(const Vector& lhv, const float c); |
Joeatsumi | 0:6a28eb668082 | 55 | float operator*(const Vector& lhv, const Vector& rhv); |
Joeatsumi | 0:6a28eb668082 | 56 |