Added reference headers and moved some code.
This commit is contained in:
@@ -10,6 +10,12 @@ include(GNUInstallDirs)
|
||||
add_library(OndselSolver STATIC)
|
||||
|
||||
set(ONDSELSOLVER_SRC
|
||||
OndselSolver/Array.cpp
|
||||
OndselSolver/FullVector.cpp
|
||||
OndselSolver/RowTypeMatrix.cpp
|
||||
OndselSolver/FullColumn.cpp
|
||||
OndselSolver/FullMatrix.cpp
|
||||
OndselSolver/FullRow.cpp
|
||||
OndselSolver/Abs.cpp
|
||||
OndselSolver/AbsConstraint.cpp
|
||||
OndselSolver/AccICKineNewtonRaphson.cpp
|
||||
@@ -25,7 +31,6 @@ set(ONDSELSOLVER_SRC
|
||||
OndselSolver/ArcSine.cpp
|
||||
OndselSolver/ArcTan.cpp
|
||||
OndselSolver/ArcTan2.cpp
|
||||
OndselSolver/Array.cpp
|
||||
OndselSolver/ASMTAnimationParameters.cpp
|
||||
OndselSolver/ASMTAssembly.cpp
|
||||
OndselSolver/ASMTConstantGravity.cpp
|
||||
@@ -146,11 +151,7 @@ set(ONDSELSOLVER_SRC
|
||||
OndselSolver/FixedJoint.cpp
|
||||
OndselSolver/ForceTorqueData.cpp
|
||||
OndselSolver/ForceTorqueItem.cpp
|
||||
OndselSolver/FullColumn.cpp
|
||||
OndselSolver/FullMatrix.cpp
|
||||
OndselSolver/FullMotion.cpp
|
||||
OndselSolver/FullRow.cpp
|
||||
OndselSolver/FullVector.cpp
|
||||
OndselSolver/Function.cpp
|
||||
OndselSolver/FunctionFromData.cpp
|
||||
OndselSolver/FunctionWithManyArgs.cpp
|
||||
@@ -248,7 +249,6 @@ set(ONDSELSOLVER_SRC
|
||||
OndselSolver/RedundantConstraint.cpp
|
||||
OndselSolver/RevCylJoint.cpp
|
||||
OndselSolver/RevoluteJoint.cpp
|
||||
OndselSolver/RowTypeMatrix.cpp
|
||||
OndselSolver/ScalarNewtonRaphson.cpp
|
||||
OndselSolver/ScrewConstraintIJ.cpp
|
||||
OndselSolver/ScrewConstraintIqcJc.cpp
|
||||
@@ -296,6 +296,12 @@ set(ONDSELSOLVER_SRC
|
||||
)
|
||||
|
||||
set(ONDSELSOLVER_HEADERS
|
||||
OndselSolver/Array.h
|
||||
OndselSolver/FullVector.h
|
||||
OndselSolver/RowTypeMatrix.h
|
||||
OndselSolver/FullRow.h
|
||||
OndselSolver/FullColumn.h
|
||||
OndselSolver/FullMatrix.h
|
||||
OndselSolver/Abs.h
|
||||
OndselSolver/AbsConstraint.h
|
||||
OndselSolver/AccICKineNewtonRaphson.h
|
||||
@@ -312,7 +318,6 @@ set(ONDSELSOLVER_HEADERS
|
||||
OndselSolver/ArcSine.h
|
||||
OndselSolver/ArcTan.h
|
||||
OndselSolver/ArcTan2.h
|
||||
OndselSolver/Array.h
|
||||
OndselSolver/ASMTAnimationParameters.h
|
||||
OndselSolver/ASMTAssembly.h
|
||||
OndselSolver/ASMTConstantGravity.h
|
||||
@@ -435,11 +440,8 @@ set(ONDSELSOLVER_HEADERS
|
||||
OndselSolver/FixedJoint.h
|
||||
OndselSolver/ForceTorqueData.h
|
||||
OndselSolver/ForceTorqueItem.h
|
||||
OndselSolver/FullColumn.h
|
||||
OndselSolver/FullMatrix.h
|
||||
OndselSolver/FullMotion.h
|
||||
OndselSolver/FullRow.h
|
||||
OndselSolver/FullVector.h
|
||||
OndselSolver/Function.h
|
||||
OndselSolver/FunctionFromData.h
|
||||
OndselSolver/FunctionWithManyArgs.h
|
||||
@@ -538,7 +540,6 @@ set(ONDSELSOLVER_HEADERS
|
||||
OndselSolver/resource.h
|
||||
OndselSolver/RevCylJoint.h
|
||||
OndselSolver/RevoluteJoint.h
|
||||
OndselSolver/RowTypeMatrix.h
|
||||
OndselSolver/ScalarNewtonRaphson.h
|
||||
OndselSolver/ScrewConstraintIJ.h
|
||||
OndselSolver/ScrewConstraintIqcJc.h
|
||||
|
||||
@@ -8,17 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DiagonalMatrix.ref.h"
|
||||
#include "Array.h"
|
||||
#include "FullColumn.h"
|
||||
#include "FullMatrix.h"
|
||||
|
||||
namespace MbD {
|
||||
template<typename T>
|
||||
class DiagonalMatrix;
|
||||
template<typename T>
|
||||
using DiagMatsptr = std::shared_ptr<DiagonalMatrix<T>>;
|
||||
using DiagMatDsptr = std::shared_ptr<DiagonalMatrix<double>>;
|
||||
|
||||
template<typename T>
|
||||
class DiagonalMatrix : public Array<T>
|
||||
{
|
||||
|
||||
11
OndselSolver/DiagonalMatrix.ref.h
Normal file
11
OndselSolver/DiagonalMatrix.ref.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace MbD {
|
||||
template<typename T>
|
||||
class DiagonalMatrix;
|
||||
template<typename T>
|
||||
using DiagMatsptr = std::shared_ptr<DiagonalMatrix<T>>;
|
||||
using DiagMatDsptr = std::shared_ptr<DiagonalMatrix<double>>;
|
||||
}
|
||||
@@ -9,3 +9,292 @@
|
||||
#include "EulerParameters.h"
|
||||
|
||||
using namespace MbD;
|
||||
template<>
|
||||
inline FMatFColDsptr EulerParameters<double>::ppApEpEtimesColumn(FColDsptr col)
|
||||
{
|
||||
double a2c0 = 2 * col->at(0);
|
||||
double a2c1 = 2 * col->at(1);
|
||||
double a2c2 = 2 * col->at(2);
|
||||
double m2c0 = 0 - a2c0;
|
||||
double m2c1 = 0 - a2c1;
|
||||
double m2c2 = 0 - a2c2;
|
||||
auto col00 = std::make_shared<FullColumn<double>>(ListD{ a2c0, m2c1, m2c2 });
|
||||
auto col01 = std::make_shared<FullColumn<double>>(ListD{ a2c1, a2c0, 0 });
|
||||
auto col02 = std::make_shared<FullColumn<double>>(ListD{ a2c2, 0, a2c0 });
|
||||
auto col03 = std::make_shared<FullColumn<double>>(ListD{ 0, m2c2, a2c1 });
|
||||
auto col11 = std::make_shared<FullColumn<double>>(ListD{ m2c0, a2c1, m2c2 });
|
||||
auto col12 = std::make_shared<FullColumn<double>>(ListD{ 0, a2c2, a2c1 });
|
||||
auto col13 = std::make_shared<FullColumn<double>>(ListD{ a2c2, 0, m2c0 });
|
||||
auto col22 = std::make_shared<FullColumn<double>>(ListD{ m2c0, m2c1, a2c2 });
|
||||
auto col23 = std::make_shared<FullColumn<double>>(ListD{ m2c1, a2c0, 0 });
|
||||
auto col33 = std::make_shared<FullColumn<double>>(ListD{ a2c0, a2c1, a2c2 });
|
||||
auto answer = std::make_shared<FullMatrix<FColDsptr>>(4, 4);
|
||||
auto& row0 = answer->at(0);
|
||||
row0->at(0) = col00;
|
||||
row0->at(1) = col01;
|
||||
row0->at(2) = col02;
|
||||
row0->at(3) = col03;
|
||||
auto& row1 = answer->at(1);
|
||||
row1->at(0) = col01;
|
||||
row1->at(1) = col11;
|
||||
row1->at(2) = col12;
|
||||
row1->at(3) = col13;
|
||||
auto& row2 = answer->at(2);
|
||||
row2->at(0) = col02;
|
||||
row2->at(1) = col12;
|
||||
row2->at(2) = col22;
|
||||
row2->at(3) = col23;
|
||||
auto& row3 = answer->at(3);
|
||||
row3->at(0) = col03;
|
||||
row3->at(1) = col13;
|
||||
row3->at(2) = col23;
|
||||
row3->at(3) = col33;
|
||||
return answer;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline FMatDsptr EulerParameters<double>::pCpEtimesColumn(FColDsptr col)
|
||||
{
|
||||
//"col size = 4."
|
||||
auto c0 = col->at(0);
|
||||
auto c1 = col->at(1);
|
||||
auto c2 = col->at(2);
|
||||
auto mc0 = -c0;
|
||||
auto mc1 = -c1;
|
||||
auto mc2 = -c2;
|
||||
auto mc3 = -col->at(3);
|
||||
auto answer = std::make_shared<FullMatrix<double>>(3, 4);
|
||||
auto& row0 = answer->at(0);
|
||||
auto& row1 = answer->at(1);
|
||||
auto& row2 = answer->at(2);
|
||||
row0->atiput(0, mc3);
|
||||
row0->atiput(1, mc2);
|
||||
row0->atiput(2, c1);
|
||||
row0->atiput(3, c0);
|
||||
row1->atiput(0, c2);
|
||||
row1->atiput(1, mc3);
|
||||
row1->atiput(2, mc0);
|
||||
row1->atiput(3, c1);
|
||||
row2->atiput(0, mc1);
|
||||
row2->atiput(1, c0);
|
||||
row2->atiput(2, mc3);
|
||||
row2->atiput(3, c2);
|
||||
return answer;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline FMatDsptr EulerParameters<T>::pCTpEtimesColumn(FColDsptr col)
|
||||
{
|
||||
//"col size = 3."
|
||||
auto c0 = col->at(0);
|
||||
auto c1 = col->at(1);
|
||||
auto c2 = col->at(2);
|
||||
auto mc0 = -c0;
|
||||
auto mc1 = -c1;
|
||||
auto mc2 = -c2;
|
||||
auto answer = std::make_shared<FullMatrix<double>>(4, 4);
|
||||
auto& row0 = answer->at(0);
|
||||
auto& row1 = answer->at(1);
|
||||
auto& row2 = answer->at(2);
|
||||
auto& row3 = answer->at(3);
|
||||
row0->atiput(0, 0.0);
|
||||
row0->atiput(1, c2);
|
||||
row0->atiput(2, mc1);
|
||||
row0->atiput(3, c0);
|
||||
row1->atiput(0, mc2);
|
||||
row1->atiput(1, 0.0);
|
||||
row1->atiput(2, c0);
|
||||
row1->atiput(3, c1);
|
||||
row2->atiput(0, c1);
|
||||
row2->atiput(1, mc0);
|
||||
row2->atiput(2, 0.0);
|
||||
row2->atiput(3, c2);
|
||||
row3->atiput(0, mc0);
|
||||
row3->atiput(1, mc1);
|
||||
row3->atiput(2, mc2);
|
||||
row3->atiput(3, 0.0);
|
||||
return answer;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline FMatFMatDsptr EulerParameters<double>::ppApEpEtimesMatrix(FMatDsptr mat)
|
||||
{
|
||||
FRowDsptr a2m0 = mat->at(0)->times(2.0);
|
||||
FRowDsptr a2m1 = mat->at(1)->times(2.0);
|
||||
FRowDsptr a2m2 = mat->at(2)->times(2.0);
|
||||
FRowDsptr m2m0 = a2m0->negated();
|
||||
FRowDsptr m2m1 = a2m1->negated();
|
||||
FRowDsptr m2m2 = a2m2->negated();
|
||||
FRowDsptr zero = std::make_shared<FullRow<double>>(3, 0.0);
|
||||
auto mat00 = std::make_shared<FullMatrix<double>>(ListFRD{ a2m0, m2m1, m2m2 });
|
||||
auto mat01 = std::make_shared<FullMatrix<double>>(ListFRD{ a2m1, a2m0, zero });
|
||||
auto mat02 = std::make_shared<FullMatrix<double>>(ListFRD{ a2m2, zero, a2m0 });
|
||||
auto mat03 = std::make_shared<FullMatrix<double>>(ListFRD{ zero, m2m2, a2m1 });
|
||||
auto mat11 = std::make_shared<FullMatrix<double>>(ListFRD{ m2m0, a2m1, m2m2 });
|
||||
auto mat12 = std::make_shared<FullMatrix<double>>(ListFRD{ zero, a2m2, a2m1 });
|
||||
auto mat13 = std::make_shared<FullMatrix<double>>(ListFRD{ a2m2, zero, m2m0 });
|
||||
auto mat22 = std::make_shared<FullMatrix<double>>(ListFRD{ m2m0, m2m1, a2m2 });
|
||||
auto mat23 = std::make_shared<FullMatrix<double>>(ListFRD{ m2m1, a2m0, zero });
|
||||
auto mat33 = std::make_shared<FullMatrix<double>>(ListFRD{ a2m0, a2m1, a2m2 });
|
||||
auto answer = std::make_shared<FullMatrix<FMatDsptr>>(4, 4);
|
||||
auto& row0 = answer->at(0);
|
||||
row0->at(0) = mat00;
|
||||
row0->at(1) = mat01;
|
||||
row0->at(2) = mat02;
|
||||
row0->at(3) = mat03;
|
||||
auto& row1 = answer->at(1);
|
||||
row1->at(0) = mat01;
|
||||
row1->at(1) = mat11;
|
||||
row1->at(2) = mat12;
|
||||
row1->at(3) = mat13;
|
||||
auto& row2 = answer->at(2);
|
||||
row2->at(0) = mat02;
|
||||
row2->at(1) = mat12;
|
||||
row2->at(2) = mat22;
|
||||
row2->at(3) = mat23;
|
||||
auto& row3 = answer->at(3);
|
||||
row3->at(0) = mat03;
|
||||
row3->at(1) = mat13;
|
||||
row3->at(2) = mat23;
|
||||
row3->at(3) = mat33;
|
||||
return answer;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void EulerParameters<double>::initialize()
|
||||
{
|
||||
aA = FullMatrix<double>::identitysptr(3);
|
||||
aB = std::make_shared<FullMatrix<double>>(3, 4);
|
||||
aC = std::make_shared<FullMatrix<double>>(3, 4);
|
||||
pApE = std::make_shared<FullColumn<FMatDsptr>>(4);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
pApE->at(i) = std::make_shared<FullMatrix<double>>(3, 3);
|
||||
}
|
||||
}
|
||||
template<typename T>
|
||||
inline void EulerParameters<T>::calc()
|
||||
{
|
||||
this->calcABC();
|
||||
this->calcpApE();
|
||||
}
|
||||
template<>
|
||||
inline void EulerParameters<double>::calcABC()
|
||||
{
|
||||
double aE0 = this->at(0);
|
||||
double aE1 = this->at(1);
|
||||
double aE2 = this->at(2);
|
||||
double aE3 = this->at(3);
|
||||
double mE0 = -aE0;
|
||||
double mE1 = -aE1;
|
||||
double mE2 = -aE2;
|
||||
FRowDsptr aBi;
|
||||
aBi = aB->at(0);
|
||||
aBi->at(0) = aE3;
|
||||
aBi->at(1) = mE2;
|
||||
aBi->at(2) = aE1;
|
||||
aBi->at(3) = mE0;
|
||||
aBi = aB->at(1);
|
||||
aBi->at(0) = aE2;
|
||||
aBi->at(1) = aE3;
|
||||
aBi->at(2) = mE0;
|
||||
aBi->at(3) = mE1;
|
||||
aBi = aB->at(2);
|
||||
aBi->at(0) = mE1;
|
||||
aBi->at(1) = aE0;
|
||||
aBi->at(2) = aE3;
|
||||
aBi->at(3) = mE2;
|
||||
FRowDsptr aCi;
|
||||
aCi = aC->at(0);
|
||||
aCi->at(0) = aE3;
|
||||
aCi->at(1) = aE2;
|
||||
aCi->at(2) = mE1;
|
||||
aCi->at(3) = mE0;
|
||||
aCi = aC->at(1);
|
||||
aCi->at(0) = mE2;
|
||||
aCi->at(1) = aE3;
|
||||
aCi->at(2) = aE0;
|
||||
aCi->at(3) = mE1;
|
||||
aCi = aC->at(2);
|
||||
aCi->at(0) = aE1;
|
||||
aCi->at(1) = mE0;
|
||||
aCi->at(2) = aE3;
|
||||
aCi->at(3) = mE2;
|
||||
|
||||
aA = aB->timesTransposeFullMatrix(aC);
|
||||
}
|
||||
template<>
|
||||
inline void EulerParameters<double>::calcpApE()
|
||||
{
|
||||
double a2E0 = 2.0 * (this->at(0));
|
||||
double a2E1 = 2.0 * (this->at(1));
|
||||
double a2E2 = 2.0 * (this->at(2));
|
||||
double a2E3 = 2.0 * (this->at(3));
|
||||
double m2E0 = -a2E0;
|
||||
double m2E1 = -a2E1;
|
||||
double m2E2 = -a2E2;
|
||||
double m2E3 = -a2E3;
|
||||
FMatDsptr pApEk;
|
||||
pApEk = pApE->at(0);
|
||||
FRowDsptr pAipEk;
|
||||
pAipEk = pApEk->at(0);
|
||||
pAipEk->at(0) = a2E0;
|
||||
pAipEk->at(1) = a2E1;
|
||||
pAipEk->at(2) = a2E2;
|
||||
pAipEk = pApEk->at(1);
|
||||
pAipEk->at(0) = a2E1;
|
||||
pAipEk->at(1) = m2E0;
|
||||
pAipEk->at(2) = m2E3;
|
||||
pAipEk = pApEk->at(2);
|
||||
pAipEk->at(0) = a2E2;
|
||||
pAipEk->at(1) = a2E3;
|
||||
pAipEk->at(2) = m2E0;
|
||||
//
|
||||
pApEk = pApE->at(1);
|
||||
pAipEk = pApEk->at(0);
|
||||
pAipEk->at(0) = m2E1;
|
||||
pAipEk->at(1) = a2E0;
|
||||
pAipEk->at(2) = a2E3;
|
||||
pAipEk = pApEk->at(1);
|
||||
pAipEk->at(0) = a2E0;
|
||||
pAipEk->at(1) = a2E1;
|
||||
pAipEk->at(2) = a2E2;
|
||||
pAipEk = pApEk->at(2);
|
||||
pAipEk->at(0) = m2E3;
|
||||
pAipEk->at(1) = a2E2;
|
||||
pAipEk->at(2) = m2E1;
|
||||
//
|
||||
pApEk = pApE->at(2);
|
||||
pAipEk = pApEk->at(0);
|
||||
pAipEk->at(0) = m2E2;
|
||||
pAipEk->at(1) = m2E3;
|
||||
pAipEk->at(2) = a2E0;
|
||||
pAipEk = pApEk->at(1);
|
||||
pAipEk->at(0) = a2E3;
|
||||
pAipEk->at(1) = m2E2;
|
||||
pAipEk->at(2) = a2E1;
|
||||
pAipEk = pApEk->at(2);
|
||||
pAipEk->at(0) = a2E0;
|
||||
pAipEk->at(1) = a2E1;
|
||||
pAipEk->at(2) = a2E2;
|
||||
//
|
||||
pApEk = pApE->at(3);
|
||||
pAipEk = pApEk->at(0);
|
||||
pAipEk->at(0) = a2E3;
|
||||
pAipEk->at(1) = m2E2;
|
||||
pAipEk->at(2) = a2E1;
|
||||
pAipEk = pApEk->at(1);
|
||||
pAipEk->at(0) = a2E2;
|
||||
pAipEk->at(1) = a2E3;
|
||||
pAipEk->at(2) = m2E0;
|
||||
pAipEk = pApEk->at(2);
|
||||
pAipEk->at(0) = m2E1;
|
||||
pAipEk->at(1) = a2E0;
|
||||
pAipEk->at(2) = a2E3;
|
||||
}
|
||||
template<typename T>
|
||||
inline void EulerParameters<T>::conditionSelf()
|
||||
{
|
||||
EulerArray<T>::conditionSelf();
|
||||
this->normalizeSelf();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "EulerParameters.ref.h"
|
||||
#include "EulerArray.h"
|
||||
#include "FullColumn.h"
|
||||
#include "FullMatrix.h"
|
||||
@@ -57,295 +58,4 @@ namespace MbD {
|
||||
FMatDsptr aC;
|
||||
FColFMatDsptr pApE;
|
||||
};
|
||||
|
||||
template<>
|
||||
inline FMatFColDsptr EulerParameters<double>::ppApEpEtimesColumn(FColDsptr col)
|
||||
{
|
||||
double a2c0 = 2 * col->at(0);
|
||||
double a2c1 = 2 * col->at(1);
|
||||
double a2c2 = 2 * col->at(2);
|
||||
double m2c0 = 0 - a2c0;
|
||||
double m2c1 = 0 - a2c1;
|
||||
double m2c2 = 0 - a2c2;
|
||||
auto col00 = std::make_shared<FullColumn<double>>(ListD{ a2c0, m2c1, m2c2 });
|
||||
auto col01 = std::make_shared<FullColumn<double>>(ListD{ a2c1, a2c0, 0 });
|
||||
auto col02 = std::make_shared<FullColumn<double>>(ListD{ a2c2, 0, a2c0 });
|
||||
auto col03 = std::make_shared<FullColumn<double>>(ListD{ 0, m2c2, a2c1 });
|
||||
auto col11 = std::make_shared<FullColumn<double>>(ListD{ m2c0, a2c1, m2c2 });
|
||||
auto col12 = std::make_shared<FullColumn<double>>(ListD{ 0, a2c2, a2c1 });
|
||||
auto col13 = std::make_shared<FullColumn<double>>(ListD{ a2c2, 0, m2c0 });
|
||||
auto col22 = std::make_shared<FullColumn<double>>(ListD{ m2c0, m2c1, a2c2 });
|
||||
auto col23 = std::make_shared<FullColumn<double>>(ListD{ m2c1, a2c0, 0 });
|
||||
auto col33 = std::make_shared<FullColumn<double>>(ListD{ a2c0, a2c1, a2c2 });
|
||||
auto answer = std::make_shared<FullMatrix<FColDsptr>>(4, 4);
|
||||
auto& row0 = answer->at(0);
|
||||
row0->at(0) = col00;
|
||||
row0->at(1) = col01;
|
||||
row0->at(2) = col02;
|
||||
row0->at(3) = col03;
|
||||
auto& row1 = answer->at(1);
|
||||
row1->at(0) = col01;
|
||||
row1->at(1) = col11;
|
||||
row1->at(2) = col12;
|
||||
row1->at(3) = col13;
|
||||
auto& row2 = answer->at(2);
|
||||
row2->at(0) = col02;
|
||||
row2->at(1) = col12;
|
||||
row2->at(2) = col22;
|
||||
row2->at(3) = col23;
|
||||
auto& row3 = answer->at(3);
|
||||
row3->at(0) = col03;
|
||||
row3->at(1) = col13;
|
||||
row3->at(2) = col23;
|
||||
row3->at(3) = col33;
|
||||
return answer;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline FMatDsptr EulerParameters<double>::pCpEtimesColumn(FColDsptr col)
|
||||
{
|
||||
//"col size = 4."
|
||||
auto c0 = col->at(0);
|
||||
auto c1 = col->at(1);
|
||||
auto c2 = col->at(2);
|
||||
auto mc0 = -c0;
|
||||
auto mc1 = -c1;
|
||||
auto mc2 = -c2;
|
||||
auto mc3 = -col->at(3);
|
||||
auto answer = std::make_shared<FullMatrix<double>>(3, 4);
|
||||
auto& row0 = answer->at(0);
|
||||
auto& row1 = answer->at(1);
|
||||
auto& row2 = answer->at(2);
|
||||
row0->atiput(0, mc3);
|
||||
row0->atiput(1, mc2);
|
||||
row0->atiput(2, c1);
|
||||
row0->atiput(3, c0);
|
||||
row1->atiput(0, c2);
|
||||
row1->atiput(1, mc3);
|
||||
row1->atiput(2, mc0);
|
||||
row1->atiput(3, c1);
|
||||
row2->atiput(0, mc1);
|
||||
row2->atiput(1, c0);
|
||||
row2->atiput(2, mc3);
|
||||
row2->atiput(3, c2);
|
||||
return answer;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline FMatDsptr EulerParameters<T>::pCTpEtimesColumn(FColDsptr col)
|
||||
{
|
||||
//"col size = 3."
|
||||
auto c0 = col->at(0);
|
||||
auto c1 = col->at(1);
|
||||
auto c2 = col->at(2);
|
||||
auto mc0 = -c0;
|
||||
auto mc1 = -c1;
|
||||
auto mc2 = -c2;
|
||||
auto answer = std::make_shared<FullMatrix<double>>(4, 4);
|
||||
auto& row0 = answer->at(0);
|
||||
auto& row1 = answer->at(1);
|
||||
auto& row2 = answer->at(2);
|
||||
auto& row3 = answer->at(3);
|
||||
row0->atiput(0, 0.0);
|
||||
row0->atiput(1, c2);
|
||||
row0->atiput(2, mc1);
|
||||
row0->atiput(3, c0);
|
||||
row1->atiput(0, mc2);
|
||||
row1->atiput(1, 0.0);
|
||||
row1->atiput(2, c0);
|
||||
row1->atiput(3, c1);
|
||||
row2->atiput(0, c1);
|
||||
row2->atiput(1, mc0);
|
||||
row2->atiput(2, 0.0);
|
||||
row2->atiput(3, c2);
|
||||
row3->atiput(0, mc0);
|
||||
row3->atiput(1, mc1);
|
||||
row3->atiput(2, mc2);
|
||||
row3->atiput(3, 0.0);
|
||||
return answer;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline FMatFMatDsptr EulerParameters<double>::ppApEpEtimesMatrix(FMatDsptr mat)
|
||||
{
|
||||
FRowDsptr a2m0 = mat->at(0)->times(2.0);
|
||||
FRowDsptr a2m1 = mat->at(1)->times(2.0);
|
||||
FRowDsptr a2m2 = mat->at(2)->times(2.0);
|
||||
FRowDsptr m2m0 = a2m0->negated();
|
||||
FRowDsptr m2m1 = a2m1->negated();
|
||||
FRowDsptr m2m2 = a2m2->negated();
|
||||
FRowDsptr zero = std::make_shared<FullRow<double>>(3, 0.0);
|
||||
auto mat00 = std::make_shared<FullMatrix<double>>(ListFRD{ a2m0, m2m1, m2m2 });
|
||||
auto mat01 = std::make_shared<FullMatrix<double>>(ListFRD{ a2m1, a2m0, zero });
|
||||
auto mat02 = std::make_shared<FullMatrix<double>>(ListFRD{ a2m2, zero, a2m0 });
|
||||
auto mat03 = std::make_shared<FullMatrix<double>>(ListFRD{ zero, m2m2, a2m1 });
|
||||
auto mat11 = std::make_shared<FullMatrix<double>>(ListFRD{ m2m0, a2m1, m2m2 });
|
||||
auto mat12 = std::make_shared<FullMatrix<double>>(ListFRD{ zero, a2m2, a2m1 });
|
||||
auto mat13 = std::make_shared<FullMatrix<double>>(ListFRD{ a2m2, zero, m2m0 });
|
||||
auto mat22 = std::make_shared<FullMatrix<double>>(ListFRD{ m2m0, m2m1, a2m2 });
|
||||
auto mat23 = std::make_shared<FullMatrix<double>>(ListFRD{ m2m1, a2m0, zero });
|
||||
auto mat33 = std::make_shared<FullMatrix<double>>(ListFRD{ a2m0, a2m1, a2m2 });
|
||||
auto answer = std::make_shared<FullMatrix<FMatDsptr>>(4, 4);
|
||||
auto& row0 = answer->at(0);
|
||||
row0->at(0) = mat00;
|
||||
row0->at(1) = mat01;
|
||||
row0->at(2) = mat02;
|
||||
row0->at(3) = mat03;
|
||||
auto& row1 = answer->at(1);
|
||||
row1->at(0) = mat01;
|
||||
row1->at(1) = mat11;
|
||||
row1->at(2) = mat12;
|
||||
row1->at(3) = mat13;
|
||||
auto& row2 = answer->at(2);
|
||||
row2->at(0) = mat02;
|
||||
row2->at(1) = mat12;
|
||||
row2->at(2) = mat22;
|
||||
row2->at(3) = mat23;
|
||||
auto& row3 = answer->at(3);
|
||||
row3->at(0) = mat03;
|
||||
row3->at(1) = mat13;
|
||||
row3->at(2) = mat23;
|
||||
row3->at(3) = mat33;
|
||||
return answer;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void EulerParameters<double>::initialize()
|
||||
{
|
||||
aA = FullMatrix<double>::identitysptr(3);
|
||||
aB = std::make_shared<FullMatrix<double>>(3, 4);
|
||||
aC = std::make_shared<FullMatrix<double>>(3, 4);
|
||||
pApE = std::make_shared<FullColumn<FMatDsptr>>(4);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
pApE->at(i) = std::make_shared<FullMatrix<double>>(3, 3);
|
||||
}
|
||||
}
|
||||
template<typename T>
|
||||
inline void EulerParameters<T>::calc()
|
||||
{
|
||||
this->calcABC();
|
||||
this->calcpApE();
|
||||
}
|
||||
template<>
|
||||
inline void EulerParameters<double>::calcABC()
|
||||
{
|
||||
double aE0 = this->at(0);
|
||||
double aE1 = this->at(1);
|
||||
double aE2 = this->at(2);
|
||||
double aE3 = this->at(3);
|
||||
double mE0 = -aE0;
|
||||
double mE1 = -aE1;
|
||||
double mE2 = -aE2;
|
||||
FRowDsptr aBi;
|
||||
aBi = aB->at(0);
|
||||
aBi->at(0) = aE3;
|
||||
aBi->at(1) = mE2;
|
||||
aBi->at(2) = aE1;
|
||||
aBi->at(3) = mE0;
|
||||
aBi = aB->at(1);
|
||||
aBi->at(0) = aE2;
|
||||
aBi->at(1) = aE3;
|
||||
aBi->at(2) = mE0;
|
||||
aBi->at(3) = mE1;
|
||||
aBi = aB->at(2);
|
||||
aBi->at(0) = mE1;
|
||||
aBi->at(1) = aE0;
|
||||
aBi->at(2) = aE3;
|
||||
aBi->at(3) = mE2;
|
||||
FRowDsptr aCi;
|
||||
aCi = aC->at(0);
|
||||
aCi->at(0) = aE3;
|
||||
aCi->at(1) = aE2;
|
||||
aCi->at(2) = mE1;
|
||||
aCi->at(3) = mE0;
|
||||
aCi = aC->at(1);
|
||||
aCi->at(0) = mE2;
|
||||
aCi->at(1) = aE3;
|
||||
aCi->at(2) = aE0;
|
||||
aCi->at(3) = mE1;
|
||||
aCi = aC->at(2);
|
||||
aCi->at(0) = aE1;
|
||||
aCi->at(1) = mE0;
|
||||
aCi->at(2) = aE3;
|
||||
aCi->at(3) = mE2;
|
||||
|
||||
aA = aB->timesTransposeFullMatrix(aC);
|
||||
}
|
||||
template<>
|
||||
inline void EulerParameters<double>::calcpApE()
|
||||
{
|
||||
double a2E0 = 2.0 * (this->at(0));
|
||||
double a2E1 = 2.0 * (this->at(1));
|
||||
double a2E2 = 2.0 * (this->at(2));
|
||||
double a2E3 = 2.0 * (this->at(3));
|
||||
double m2E0 = -a2E0;
|
||||
double m2E1 = -a2E1;
|
||||
double m2E2 = -a2E2;
|
||||
double m2E3 = -a2E3;
|
||||
FMatDsptr pApEk;
|
||||
pApEk = pApE->at(0);
|
||||
FRowDsptr pAipEk;
|
||||
pAipEk = pApEk->at(0);
|
||||
pAipEk->at(0) = a2E0;
|
||||
pAipEk->at(1) = a2E1;
|
||||
pAipEk->at(2) = a2E2;
|
||||
pAipEk = pApEk->at(1);
|
||||
pAipEk->at(0) = a2E1;
|
||||
pAipEk->at(1) = m2E0;
|
||||
pAipEk->at(2) = m2E3;
|
||||
pAipEk = pApEk->at(2);
|
||||
pAipEk->at(0) = a2E2;
|
||||
pAipEk->at(1) = a2E3;
|
||||
pAipEk->at(2) = m2E0;
|
||||
//
|
||||
pApEk = pApE->at(1);
|
||||
pAipEk = pApEk->at(0);
|
||||
pAipEk->at(0) = m2E1;
|
||||
pAipEk->at(1) = a2E0;
|
||||
pAipEk->at(2) = a2E3;
|
||||
pAipEk = pApEk->at(1);
|
||||
pAipEk->at(0) = a2E0;
|
||||
pAipEk->at(1) = a2E1;
|
||||
pAipEk->at(2) = a2E2;
|
||||
pAipEk = pApEk->at(2);
|
||||
pAipEk->at(0) = m2E3;
|
||||
pAipEk->at(1) = a2E2;
|
||||
pAipEk->at(2) = m2E1;
|
||||
//
|
||||
pApEk = pApE->at(2);
|
||||
pAipEk = pApEk->at(0);
|
||||
pAipEk->at(0) = m2E2;
|
||||
pAipEk->at(1) = m2E3;
|
||||
pAipEk->at(2) = a2E0;
|
||||
pAipEk = pApEk->at(1);
|
||||
pAipEk->at(0) = a2E3;
|
||||
pAipEk->at(1) = m2E2;
|
||||
pAipEk->at(2) = a2E1;
|
||||
pAipEk = pApEk->at(2);
|
||||
pAipEk->at(0) = a2E0;
|
||||
pAipEk->at(1) = a2E1;
|
||||
pAipEk->at(2) = a2E2;
|
||||
//
|
||||
pApEk = pApE->at(3);
|
||||
pAipEk = pApEk->at(0);
|
||||
pAipEk->at(0) = a2E3;
|
||||
pAipEk->at(1) = m2E2;
|
||||
pAipEk->at(2) = a2E1;
|
||||
pAipEk = pApEk->at(1);
|
||||
pAipEk->at(0) = a2E2;
|
||||
pAipEk->at(1) = a2E3;
|
||||
pAipEk->at(2) = m2E0;
|
||||
pAipEk = pApEk->at(2);
|
||||
pAipEk->at(0) = m2E1;
|
||||
pAipEk->at(1) = a2E0;
|
||||
pAipEk->at(2) = a2E3;
|
||||
}
|
||||
template<typename T>
|
||||
inline void EulerParameters<T>::conditionSelf()
|
||||
{
|
||||
EulerArray<T>::conditionSelf();
|
||||
this->normalizeSelf();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
6
OndselSolver/EulerParameters.ref.h
Normal file
6
OndselSolver/EulerParameters.ref.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace MbD {
|
||||
template<typename T>
|
||||
class EulerParameters;
|
||||
}
|
||||
@@ -12,17 +12,21 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "FullVector.h"
|
||||
#include "FullColumn.ref.h"
|
||||
#include "FullRow.ref.h"
|
||||
#include "FullColumn.h"
|
||||
#include "FullRow.h"
|
||||
|
||||
namespace MbD {
|
||||
template<typename T>
|
||||
class FullColumn;
|
||||
using FColDsptr = std::shared_ptr<FullColumn<double>>;
|
||||
template<typename T>
|
||||
using FColsptr = std::shared_ptr<FullColumn<T>>;
|
||||
template<typename T>
|
||||
class FullRow;
|
||||
template<typename T>
|
||||
using FRowsptr = std::shared_ptr<FullRow<T>>;
|
||||
// template<typename T>
|
||||
// class FullColumn;
|
||||
// using FColDsptr = std::shared_ptr<FullColumn<double>>;
|
||||
// template<typename T>
|
||||
// using FColsptr = std::shared_ptr<FullColumn<T>>;
|
||||
// template<typename T>
|
||||
// class FullRow;
|
||||
// template<typename T>
|
||||
// using FRowsptr = std::shared_ptr<FullRow<T>>;
|
||||
class Symbolic;
|
||||
|
||||
template<typename T>
|
||||
|
||||
11
OndselSolver/FullColumn.ref.h
Normal file
11
OndselSolver/FullColumn.ref.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
namespace MbD {
|
||||
template<typename T>
|
||||
class FullColumn;
|
||||
|
||||
using FColDsptr = std::shared_ptr<FullColumn<double>>;
|
||||
|
||||
template<typename T>
|
||||
using FColsptr = std::shared_ptr<FullColumn<T>>;
|
||||
}
|
||||
@@ -7,9 +7,218 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "FullMatrix.h"
|
||||
#include "FullColumn.h"
|
||||
#include "FullRow.h"
|
||||
#include "DiagonalMatrix.h"
|
||||
#include "EulerParameters.h"
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatex(T the)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, 1.0);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, cthe);
|
||||
row1->atiput(2, -sthe);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, sthe);
|
||||
row2->atiput(2, cthe);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatey(T the)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, cthe);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, sthe);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, 1.0);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, -sthe);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, cthe);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatez(T the)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, cthe);
|
||||
row0->atiput(1, -sthe);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, sthe);
|
||||
row1->atiput(1, cthe);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, 1.0);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatexrotDot(T the, T thedot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, 0.0);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, cthedot);
|
||||
row1->atiput(2, -sthedot);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, sthedot);
|
||||
row2->atiput(2, cthedot);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotateyrotDot(T the, T thedot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, cthedot);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, sthedot);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, 0.0);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, -sthedot);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, cthedot);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatezrotDot(T the, T thedot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, cthedot);
|
||||
row0->atiput(1, -sthedot);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, sthedot);
|
||||
row1->atiput(1, cthedot);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, 0.0);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatexrotDotrotDDot(T the, T thedot, T theddot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto stheddot = cthedot * thedot + (cthe * theddot);
|
||||
auto ctheddot = -(sthedot * thedot) - (sthe * theddot);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, 0.0);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, ctheddot);
|
||||
row1->atiput(2, -stheddot);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, stheddot);
|
||||
row2->atiput(2, ctheddot);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotateyrotDotrotDDot(T the, T thedot, T theddot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto stheddot = cthedot * thedot + (cthe * theddot);
|
||||
auto ctheddot = -(sthedot * thedot) - (sthe * theddot);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, ctheddot);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, stheddot);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, 0.0);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, -stheddot);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, ctheddot);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatezrotDotrotDDot(T the, T thedot, T theddot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto stheddot = cthedot * thedot + (cthe * theddot);
|
||||
auto ctheddot = -(sthedot * thedot) - (sthe * theddot);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, ctheddot);
|
||||
row0->atiput(1, -stheddot);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, stheddot);
|
||||
row1->atiput(1, ctheddot);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, 0.0);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::identitysptr(int n)
|
||||
{
|
||||
auto mat = std::make_shared<FullMatrix<T>>(n, n);
|
||||
mat->identity();
|
||||
return mat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::tildeMatrix(FColDsptr col)
|
||||
{
|
||||
|
||||
@@ -11,38 +11,14 @@
|
||||
#include "corecrt_math_defines.h"
|
||||
#include <memory>
|
||||
|
||||
#include "FullRow.h"
|
||||
#include "FullMatrix.ref.h"
|
||||
#include "FullColumn.ref.h"
|
||||
#include "FullRow.ref.h"
|
||||
#include "DiagonalMatrix.ref.h"
|
||||
#include "EulerParameters.ref.h"
|
||||
#include "RowTypeMatrix.h"
|
||||
#include "FullColumn.h"
|
||||
|
||||
namespace MbD {
|
||||
template<typename T>
|
||||
class FullMatrix;
|
||||
|
||||
using FMatDsptr = std::shared_ptr<FullMatrix<double>>;
|
||||
|
||||
template<typename T>
|
||||
using FMatsptr = std::shared_ptr<FullMatrix<T>>;
|
||||
|
||||
template<typename T>
|
||||
class FullColumn;
|
||||
using FColDsptr = std::shared_ptr<FullColumn<double>>;
|
||||
|
||||
template<typename T>
|
||||
class FullRow;
|
||||
|
||||
template<typename T>
|
||||
class RowTypeMatrix;
|
||||
|
||||
template<typename T>
|
||||
class EulerParameters;
|
||||
|
||||
template<typename T>
|
||||
class DiagonalMatrix;
|
||||
|
||||
using FMatFColDsptr = std::shared_ptr<FullMatrix<FColDsptr>>;
|
||||
using FMatFMatDsptr = std::shared_ptr<FullMatrix<FMatDsptr>>;
|
||||
using FColFMatDsptr = std::shared_ptr<FullColumn<FMatDsptr>>;
|
||||
|
||||
template<typename T>
|
||||
class FullMatrix : public RowTypeMatrix<FRowsptr<T>>
|
||||
@@ -118,210 +94,5 @@ namespace MbD {
|
||||
|
||||
std::ostream& printOn(std::ostream& s) const override;
|
||||
};
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatex(T the)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, 1.0);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, cthe);
|
||||
row1->atiput(2, -sthe);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, sthe);
|
||||
row2->atiput(2, cthe);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatey(T the)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, cthe);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, sthe);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, 1.0);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, -sthe);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, cthe);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatez(T the)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, cthe);
|
||||
row0->atiput(1, -sthe);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, sthe);
|
||||
row1->atiput(1, cthe);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, 1.0);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatexrotDot(T the, T thedot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, 0.0);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, cthedot);
|
||||
row1->atiput(2, -sthedot);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, sthedot);
|
||||
row2->atiput(2, cthedot);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotateyrotDot(T the, T thedot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, cthedot);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, sthedot);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, 0.0);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, -sthedot);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, cthedot);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatezrotDot(T the, T thedot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, cthedot);
|
||||
row0->atiput(1, -sthedot);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, sthedot);
|
||||
row1->atiput(1, cthedot);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, 0.0);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatexrotDotrotDDot(T the, T thedot, T theddot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto stheddot = cthedot * thedot + (cthe * theddot);
|
||||
auto ctheddot = -(sthedot * thedot) - (sthe * theddot);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, 0.0);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, ctheddot);
|
||||
row1->atiput(2, -stheddot);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, stheddot);
|
||||
row2->atiput(2, ctheddot);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotateyrotDotrotDDot(T the, T thedot, T theddot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto stheddot = cthedot * thedot + (cthe * theddot);
|
||||
auto ctheddot = -(sthedot * thedot) - (sthe * theddot);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, ctheddot);
|
||||
row0->atiput(1, 0.0);
|
||||
row0->atiput(2, stheddot);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, 0.0);
|
||||
row1->atiput(1, 0.0);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, -stheddot);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, ctheddot);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::rotatezrotDotrotDDot(T the, T thedot, T theddot)
|
||||
{
|
||||
auto sthe = std::sin(the);
|
||||
auto cthe = std::cos(the);
|
||||
auto sthedot = cthe * thedot;
|
||||
auto cthedot = -sthe * thedot;
|
||||
auto stheddot = cthedot * thedot + (cthe * theddot);
|
||||
auto ctheddot = -(sthedot * thedot) - (sthe * theddot);
|
||||
auto rotMat = std::make_shared<FullMatrix<T>>(3, 3);
|
||||
auto row0 = rotMat->at(0);
|
||||
row0->atiput(0, ctheddot);
|
||||
row0->atiput(1, -stheddot);
|
||||
row0->atiput(2, 0.0);
|
||||
auto row1 = rotMat->at(1);
|
||||
row1->atiput(0, stheddot);
|
||||
row1->atiput(1, ctheddot);
|
||||
row1->atiput(2, 0.0);
|
||||
auto row2 = rotMat->at(2);
|
||||
row2->atiput(0, 0.0);
|
||||
row2->atiput(1, 0.0);
|
||||
row2->atiput(2, 0.0);
|
||||
return rotMat;
|
||||
}
|
||||
template<typename T>
|
||||
inline FMatsptr<T> FullMatrix<T>::identitysptr(int n)
|
||||
{
|
||||
auto mat = std::make_shared<FullMatrix<T>>(n, n);
|
||||
mat->identity();
|
||||
return mat;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
20
OndselSolver/FullMatrix.ref.h
Normal file
20
OndselSolver/FullMatrix.ref.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "FullColumn.ref.h"
|
||||
|
||||
namespace MbD {
|
||||
template<typename T>
|
||||
class FullMatrix;
|
||||
|
||||
using FMatDsptr = std::shared_ptr<MbD::FullMatrix<double>>;
|
||||
|
||||
template<typename T>
|
||||
using FMatsptr = std::shared_ptr<FullMatrix<T>>;
|
||||
|
||||
using FMatFColDsptr = std::shared_ptr<FullMatrix<FColDsptr>>;
|
||||
using FMatFMatDsptr = std::shared_ptr<FullMatrix<FMatDsptr>>;
|
||||
|
||||
using FColFMatDsptr = std::shared_ptr<FullColumn<FMatDsptr>>;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "FullRow.h"
|
||||
#include "FullMatrix.h"
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
@@ -15,7 +16,7 @@ FMatsptr<T> FullRow<T>::transposeTimesFullRow(FRowsptr<T> fullRow)
|
||||
{
|
||||
//"a*b = a(i)b(j)"
|
||||
auto nrow = (int)this->size();
|
||||
auto answer = std::make_shared<MbD::FullMatrix<double>>(nrow);
|
||||
auto answer = std::make_shared<FullMatrix<double>>(nrow);
|
||||
for (int i = 0; i < nrow; i++)
|
||||
{
|
||||
answer->atiput(i, fullRow->times(this->at(i)));
|
||||
|
||||
@@ -9,21 +9,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "FullVector.h"
|
||||
#include "FullMatrix.h"
|
||||
#include "FullMatrix.ref.h"
|
||||
#include "FullRow.ref.h"
|
||||
|
||||
namespace MbD {
|
||||
template<typename T>
|
||||
class FullRow;
|
||||
template<typename T>
|
||||
using FRowsptr = std::shared_ptr<FullRow<T>>;
|
||||
using FRowDsptr = std::shared_ptr<FullRow<double>>;
|
||||
template<typename T>
|
||||
class FullColumn;
|
||||
template<typename T>
|
||||
using FColsptr = std::shared_ptr<FullColumn<T>>;
|
||||
using ListFRD = std::initializer_list<FRowDsptr>;
|
||||
template<typename T>
|
||||
class FullMatrix;
|
||||
|
||||
template<typename T>
|
||||
class FullRow : public FullVector<T>
|
||||
|
||||
14
OndselSolver/FullRow.ref.h
Normal file
14
OndselSolver/FullRow.ref.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "FullColumn.ref.h"
|
||||
|
||||
namespace MbD {
|
||||
template<typename T>
|
||||
class FullRow;
|
||||
|
||||
template<typename T>
|
||||
using FRowsptr = std::shared_ptr<FullRow<T>>;
|
||||
using FRowDsptr = std::shared_ptr<FullRow<double>>;
|
||||
|
||||
using ListFRD = std::initializer_list<FRowDsptr>;
|
||||
}
|
||||
@@ -9,3 +9,13 @@
|
||||
#include "RowTypeMatrix.h"
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
template<typename T>
|
||||
int RowTypeMatrix<T>::nrow() {
|
||||
return (int) this->size();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int RowTypeMatrix<T>::ncol() {
|
||||
return this->at(0)->numberOfElements();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Array.h"
|
||||
#include "FullRow.h"
|
||||
#include "FullRow.ref.h"
|
||||
|
||||
namespace MbD {
|
||||
|
||||
@@ -24,13 +24,8 @@ namespace MbD {
|
||||
virtual void zeroSelf() override = 0;
|
||||
//double maxMagnitude() override;
|
||||
int numberOfElements() override;
|
||||
|
||||
int nrow() {
|
||||
return (int) this->size();
|
||||
}
|
||||
int ncol() {
|
||||
return this->at(0)->numberOfElements();
|
||||
}
|
||||
int nrow();
|
||||
int ncol();
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FullRow.h"
|
||||
#include "LinearMultiStepMethod.h"
|
||||
|
||||
namespace MbD {
|
||||
|
||||
Reference in New Issue
Block a user