慣性航法で用いられる座標変換をプログラムにしました。ECI座標の初期位置を設定した後、ECI,ECEF,NED,機体座標系の変換を行います。行列計算の方法や値の設定などは、ヘッダーファイル内の記述を見れば分かると思います。 また計算結果はTeratermで確認する事が出来ます。 (行列を見る場合はtoString関数、ベクトルを見る場合はtoString_V関数を使用します)

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Vector_Matrix_operator.cpp Source File

Vector_Matrix_operator.cpp

00001 #include "Vector_Matrix_operator.h"
00002 
00003 Vector operator*(const Matrix& lhm, const Vector& rhv) {
00004     if (lhm.GetCol() != rhv.GetDim()) error("Irregular Dimention");
00005     Vector retVec(lhm.GetRow());
00006 
00007     for (int i = 1; i <= lhm.GetRow(); i++) {
00008         float temp = 0.0f;
00009         for (int j = 1; j <= rhv.GetDim(); j++) {
00010             temp += lhm.GetComp(i, j)*rhv.GetComp(j);
00011         }
00012         retVec.SetComp(i, temp);
00013     }
00014 
00015     retVec.CleanUp();
00016 
00017     return retVec;
00018 }
00019 
00020 Vector operator*(const Vector& lhv, const Matrix& rhm) {
00021     if (lhv.GetDim() != rhm.GetRow()) error("Irregular Dimention");
00022     Vector retVec(rhm.GetCol());
00023 
00024     for (int i = 1; i <= rhm.GetCol(); i++) {
00025         float temp = 0.0f;
00026         for (int j = 1; j <= lhv.GetDim(); j++) {
00027             temp += lhv.GetComp(j) * rhm.GetComp(j, i);
00028         }
00029         retVec.SetComp(i, temp);
00030     }
00031 
00032     retVec.CleanUp();
00033 
00034     return retVec;
00035 }