From 697aad4db9fd34579d325da08cfb699004391cec Mon Sep 17 00:00:00 2001 From: Aik-Siong Koh Date: Tue, 2 May 2023 10:22:37 -0600 Subject: [PATCH] first good build. Part, PartFrame, Matrix --- MbDCode/AbsConstraint.h | 3 +- MbDCode/CartesianFrame.h | 3 +- MbDCode/CylindricalJoint.cpp | 1 + MbDCode/CylindricalJoint.h | 9 ++ MbDCode/EndFramec.h | 2 +- MbDCode/EndFrameqc.h | 9 +- MbDCode/EndFrameqct.h | 3 +- MbDCode/FullColumn.cpp | 11 --- MbDCode/FullColumn.h | 34 +++++-- MbDCode/FullMatrix.cpp | 7 -- MbDCode/FullMatrix.cpp.bak | 5 ++ MbDCode/FullMatrix.h | 40 ++++++--- MbDCode/FullMatrix.h.bak | 29 ++++++ MbDCode/Joint.cpp | 5 ++ MbDCode/Joint.h | 19 +++- MbDCode/MarkerFrame.cpp | 4 +- MbDCode/MarkerFrame.h | 8 +- MbDCode/MbDCode.cpp | 153 +++++++++++++++++++++++--------- MbDCode/MbDCode.vcxproj | 16 ++++ MbDCode/MbDCode.vcxproj.filters | 54 +++++++++++ MbDCode/NewtonRaphson.h | 3 +- MbDCode/PrescribedMotion.cpp | 1 + MbDCode/PrescribedMotion.h | 9 ++ MbDCode/RevoluteJoint.cpp | 1 + MbDCode/RevoluteJoint.h | 8 ++ MbDCode/SparseColumn.cpp | 1 + MbDCode/SparseColumn.h | 14 +++ MbDCode/SparseMatrix.cpp | 1 + MbDCode/SparseMatrix.h | 22 +++++ MbDCode/SparseRow.cpp | 1 + MbDCode/SparseRow.h | 18 ++++ MbDCode/SparseVector.cpp | 1 + MbDCode/SparseVector.h | 27 ++++++ MbDCode/System.cpp | 2 + MbDCode/System.h | 2 + MbDCode/Vector.h | 2 + MbDCode/Vector.h.bak | 14 +++ MbDCode/ZRotation.cpp | 1 + MbDCode/ZRotation.h | 9 ++ 39 files changed, 453 insertions(+), 99 deletions(-) create mode 100644 MbDCode/CylindricalJoint.cpp create mode 100644 MbDCode/CylindricalJoint.h create mode 100644 MbDCode/FullMatrix.cpp.bak create mode 100644 MbDCode/FullMatrix.h.bak create mode 100644 MbDCode/PrescribedMotion.cpp create mode 100644 MbDCode/PrescribedMotion.h create mode 100644 MbDCode/RevoluteJoint.cpp create mode 100644 MbDCode/RevoluteJoint.h create mode 100644 MbDCode/SparseColumn.cpp create mode 100644 MbDCode/SparseColumn.h create mode 100644 MbDCode/SparseMatrix.cpp create mode 100644 MbDCode/SparseMatrix.h create mode 100644 MbDCode/SparseRow.cpp create mode 100644 MbDCode/SparseRow.h create mode 100644 MbDCode/SparseVector.cpp create mode 100644 MbDCode/SparseVector.h create mode 100644 MbDCode/Vector.h.bak create mode 100644 MbDCode/ZRotation.cpp create mode 100644 MbDCode/ZRotation.h diff --git a/MbDCode/AbsConstraint.h b/MbDCode/AbsConstraint.h index d18ff60..692ebad 100644 --- a/MbDCode/AbsConstraint.h +++ b/MbDCode/AbsConstraint.h @@ -1,8 +1,7 @@ #pragma once #include "Constraint.h" namespace MbD { - class AbsConstraint : - public Constraint + class AbsConstraint : public Constraint { //axis iqXminusOnePlusAxis int axis; diff --git a/MbDCode/CartesianFrame.h b/MbDCode/CartesianFrame.h index ef75b69..545bfbc 100644 --- a/MbDCode/CartesianFrame.h +++ b/MbDCode/CartesianFrame.h @@ -2,8 +2,7 @@ #include "Item.h" namespace MbD { - class CartesianFrame : - public Item + class CartesianFrame : public Item { }; } diff --git a/MbDCode/CylindricalJoint.cpp b/MbDCode/CylindricalJoint.cpp new file mode 100644 index 0000000..ae20cdd --- /dev/null +++ b/MbDCode/CylindricalJoint.cpp @@ -0,0 +1 @@ +#include "CylindricalJoint.h" diff --git a/MbDCode/CylindricalJoint.h b/MbDCode/CylindricalJoint.h new file mode 100644 index 0000000..df0ae0a --- /dev/null +++ b/MbDCode/CylindricalJoint.h @@ -0,0 +1,9 @@ +#pragma once +#include "Joint.h" + +namespace MbD { + class CylindricalJoint : public Joint + { + }; +} + diff --git a/MbDCode/EndFramec.h b/MbDCode/EndFramec.h index 5dcab49..232e185 100644 --- a/MbDCode/EndFramec.h +++ b/MbDCode/EndFramec.h @@ -15,7 +15,7 @@ namespace MbD { void setMarkerFrame(MarkerFrame* markerFrm); MarkerFrame* markerFrame; - FullColumn* rOeO = new FullColumn(3); + FullColDptr rOeO = std::make_shared>(3); FullMatDptr aAOe = std::make_shared>(3, 3); }; } diff --git a/MbDCode/EndFrameqc.h b/MbDCode/EndFrameqc.h index f3c0e01..d4d41e0 100644 --- a/MbDCode/EndFrameqc.h +++ b/MbDCode/EndFrameqc.h @@ -12,9 +12,12 @@ namespace MbD { public: EndFrameqc(); FullMatDptr prOeOpE = std::make_shared>(3, 4); - FullMatrix>* pprOeOpEpE = new FullMatrix>(3, 4); - FullColumn>* pAOepE = new FullColumn>(4); - FullMatrix>* ppAOepEpE = new FullMatrix>(4, 4); + //std::shared_ptr>>> pprOeOpEpE = std::make_shared>>>(3, 4); + std::shared_ptr>>> pAOepE = std::make_shared>>>(4); + //std::shared_ptr>>> ppAOepEpE = std::make_shared>>>(4, 4); + //FullMatrix>* pprOeOpEpE1 = new FullMatrix>(3, 4); + //FullColumn>* pAOepE1 = new FullColumn>(4); + //FullMatrix>* ppAOepEpE1 = new FullMatrix>(4, 4); }; } diff --git a/MbDCode/EndFrameqct.h b/MbDCode/EndFrameqct.h index 2365cdf..2e90cdd 100644 --- a/MbDCode/EndFrameqct.h +++ b/MbDCode/EndFrameqct.h @@ -1,8 +1,7 @@ #pragma once #include "EndFrameqc.h" namespace MbD { - class EndFrameqct : - public EndFrameqc + class EndFrameqct : public EndFrameqc { }; } diff --git a/MbDCode/FullColumn.cpp b/MbDCode/FullColumn.cpp index 3a73cf2..4cd7c60 100644 --- a/MbDCode/FullColumn.cpp +++ b/MbDCode/FullColumn.cpp @@ -3,14 +3,3 @@ #include "FullColumn.h" using namespace MbD; - -std::string FullColumn::toString() { - std::stringstream ss; - - ss << "FullColumn { "; - for (int i = 0; i < this->size() - 1; i++) { - ss << this->at(i) << ", "; - } - ss << this->back() << " }"; - return ss.str(); -} diff --git a/MbDCode/FullColumn.h b/MbDCode/FullColumn.h index e418c02..ec524e4 100644 --- a/MbDCode/FullColumn.h +++ b/MbDCode/FullColumn.h @@ -1,15 +1,31 @@ #pragma once +#include +#include + #include "Vector.h" +#include "FullMatrix.h" namespace MbD { - template - class FullColumn : public Vector - { - public: - FullColumn(int i) : Vector(i) {} - FullColumn(std::initializer_list list) : Vector{ list } {} - std::string toString(); - }; + template + class FullColumn : public Vector + { + public: + FullColumn(int i) : Vector(i) {} + FullColumn(std::initializer_list list) : Vector{ list } {} + std::string toString() + { + std::stringstream ss; + + ss << "FullColumn { "; + for (int i = 0; i < this->size() - 1; i++) { + ss << this->at(i) << ", "; + } + ss << this->back() << " }"; + return ss.str(); + } + }; + + typedef std::shared_ptr> FullColDptr; + //typedef std::shared_ptr>>> FullColFMptr; } -typedef std::shared_ptr> FullColDptr; diff --git a/MbDCode/FullMatrix.cpp b/MbDCode/FullMatrix.cpp index f5284fc..e1a598e 100644 --- a/MbDCode/FullMatrix.cpp +++ b/MbDCode/FullMatrix.cpp @@ -2,10 +2,3 @@ using namespace MbD; -FullMatrix::FullMatrix(int m, int n) { - for (int i = 0; i < m; i++) { - auto row = std::make_shared>(n); - this->push_back(row); - } -} - diff --git a/MbDCode/FullMatrix.cpp.bak b/MbDCode/FullMatrix.cpp.bak new file mode 100644 index 0000000..e74852e --- /dev/null +++ b/MbDCode/FullMatrix.cpp.bak @@ -0,0 +1,5 @@ +#include "FullMatrix.h" +#include "FullRow.h" + +using namespace MbD; + diff --git a/MbDCode/FullMatrix.h b/MbDCode/FullMatrix.h index 97e425b..50e9461 100644 --- a/MbDCode/FullMatrix.h +++ b/MbDCode/FullMatrix.h @@ -1,18 +1,36 @@ #pragma once +#include + #include "RowTypeMatrix.h" +#include "FullColumn.h" #include "FullRow.h" namespace MbD { - template - class FullMatrix : public RowTypeMatrix>> - { - public: - FullMatrix() { - // constructor code here - } - FullMatrix(int m, int n); - //FullMatrix(std::initializer_list list) : RowTypeMatrix>{ list } {} - }; + //class FullColumn; + + template + class FullMatrix : public RowTypeMatrix>> + { + public: + FullMatrix() {} + FullMatrix(int m, int n) { + for (int i = 0; i < m; i++) { + auto row = std::make_shared>(n); + this->push_back(row); + } + } + FullMatrix(std::initializer_list> list2D) { + for (auto rowList : list2D) + { + auto row = std::make_shared>(rowList); + this->push_back(row); + } + } + }; + + typedef std::initializer_list> ListListD; + typedef std::shared_ptr> FullMatDptr; + //typedef std::shared_ptr>>> FullMatFCptr; + //typedef std::shared_ptr>>> FullMatFMptr; } -typedef std::shared_ptr> FullMatDptr; diff --git a/MbDCode/FullMatrix.h.bak b/MbDCode/FullMatrix.h.bak new file mode 100644 index 0000000..fbfdec3 --- /dev/null +++ b/MbDCode/FullMatrix.h.bak @@ -0,0 +1,29 @@ +#pragma once +#include + +#include "RowTypeMatrix.h" +#include "FullColumn.h" +#include "FullRow.h" + +namespace MbD { + //class FullColumn; + + template + class FullMatrix : public RowTypeMatrix>> + { + public: + FullMatrix() {} + FullMatrix(int m, int n) { + for (int i = 0; i < m; i++) { + auto row = std::make_shared>(n); + this->push_back(row); + } + } + FullMatrix(std::initializer_list> list) : RowTypeMatrix>{ list } {} + }; + + typedef std::shared_ptr> FullMatDptr; + //typedef std::shared_ptr>>> FullMatFCptr; + //typedef std::shared_ptr>>> FullMatFMptr; +} + diff --git a/MbDCode/Joint.cpp b/MbDCode/Joint.cpp index f99eb74..18f2965 100644 --- a/MbDCode/Joint.cpp +++ b/MbDCode/Joint.cpp @@ -1 +1,6 @@ #include "Joint.h" + +MbD::Joint::Joint() +{ + +} diff --git a/MbDCode/Joint.h b/MbDCode/Joint.h index d13b886..b51d39d 100644 --- a/MbDCode/Joint.h +++ b/MbDCode/Joint.h @@ -1,9 +1,24 @@ #pragma once +#include +#include + #include "Item.h" +#include "EndFramec.h" +#include "Constraint.h" + namespace MbD { - class Joint : - public Item + class EndFramec; + class Constraint; + + class Joint : public Item { + //frmI frmJ constraints friction + public: + Joint(); + std::shared_ptr frmI; + std::shared_ptr frmJ; + std::vector> constraints; + }; } diff --git a/MbDCode/MarkerFrame.cpp b/MbDCode/MarkerFrame.cpp index 2112ab5..eb17bd0 100644 --- a/MbDCode/MarkerFrame.cpp +++ b/MbDCode/MarkerFrame.cpp @@ -1,4 +1,6 @@ #include "MarkerFrame.h" +#include "EndFramec.h" +#include "EndFrameqc.h" using namespace MbD; @@ -25,7 +27,7 @@ void MarkerFrame::setaApm(FullMatDptr x) { aApm->copy(x); } -void MarkerFrame::addEndFrame(std::shared_ptr endFrm) +void MarkerFrame::addEndFrame(std::shared_ptr endFrm) { endFrm->setMarkerFrame(this); endFrames.push_back(endFrm); diff --git a/MbDCode/MarkerFrame.h b/MbDCode/MarkerFrame.h index eaecba9..2073f6e 100644 --- a/MbDCode/MarkerFrame.h +++ b/MbDCode/MarkerFrame.h @@ -5,11 +5,11 @@ #include "PartFrame.h" #include "FullColumn.h" #include "FullMatrix.h" -#include "EndFrameqc.h" +#include "EndFramec.h" namespace MbD { class PartFrame; - class EndFrameqc; + class EndFramec; class MarkerFrame : public CartesianFrame { @@ -19,7 +19,7 @@ namespace MbD { void setPartFrame(PartFrame* partFrm); void setrpmp(FullColDptr x); void setaApm(FullMatDptr x); - void addEndFrame(std::shared_ptr x); + void addEndFrame(std::shared_ptr x); PartFrame* partFrame; FullColDptr rpmp = std::make_shared>(3); @@ -28,7 +28,7 @@ namespace MbD { FullMatDptr aAOm = std::make_shared>(3, 3); FullMatDptr prOmOpE = std::make_shared>(3, 4); FullColumn>* pAOmpE = new FullColumn>(4); - std::vector> endFrames; + std::vector> endFrames; }; } diff --git a/MbDCode/MbDCode.cpp b/MbDCode/MbDCode.cpp index 0a4f8b1..a787591 100644 --- a/MbDCode/MbDCode.cpp +++ b/MbDCode/MbDCode.cpp @@ -3,6 +3,10 @@ #include "FullColumn.h" #include "FullMatrix.h" #include "Part.h" +#include "Joint.h" +#include "CylindricalJoint.h" +#include "RevoluteJoint.h" +#include "ZRotation.h" #include "MbDCode.h" using namespace MbD; @@ -18,8 +22,7 @@ int main() FullColDptr rpmp; FullMatDptr aApm; FullRowDptr fullRow; - auto elements = { 0.0, 0.0, 0.0, 1.0 }; - auto row = std::make_shared>(elements); + auto row = std::make_shared>(ListD{ 0.0, 0.0, 0.0, 1.0 }); fullRow = std::make_shared>(4); fullRow->copy(row); // @@ -27,10 +30,8 @@ int main() str = "Assembly1"; assembly1->setName(str); std::cout << "assembly1->getName() " << assembly1->getName() << std::endl; - elements = { 0, 0, 0 }; - qX = std::make_shared>(elements); - elements = { 0, 0, 0, 1 }; - qE = std::make_shared>(elements); + qX = std::make_shared>(ListD{ 0, 0, 0 }); + qE = std::make_shared>(ListD{ 0, 0, 0, 1 }); assembly1->setqX(qX); assembly1->setqE(qE); std::cout << "assembly1->getqX() " << assembly1->getqX()->toString() << std::endl; @@ -40,38 +41,26 @@ int main() auto marker1 = std::make_shared(); str = "Marker1"; marker1->setName(str); - elements = { 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; - rpmp = std::make_shared>(elements); + rpmp = std::make_shared>(ListD{ 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }); marker1->setrpmp(rpmp); - aApm = std::make_shared>(); - elements = { 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; - fullRow = std::make_shared>(elements); - aApm->push_back(fullRow); - elements = { 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; - fullRow = std::make_shared>(elements); - aApm->push_back(fullRow); - elements = { 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; - fullRow = std::make_shared>(elements); - aApm->push_back(fullRow); + aApm = std::make_shared>(ListListD{ + { 1, 0, 0 }, + { 0, 0, 1 }, + { 0, -1, 0 } + }); marker1->setaApm(aApm); assembly1->partFrame->addMarkerFrame(marker1); // auto marker2 = std::make_shared(); str = "Marker2"; marker2->setName(str); - elements = { 0.0, 0.0, 0.0 }; - rpmp = std::make_shared>(elements); + rpmp = std::make_shared>(ListD{ 0.0, 0.0, 0.0 }); marker2->setrpmp(rpmp); - aApm = std::make_shared>(); - elements = { 1.0, 0.0, 0.0 }; - fullRow = std::make_shared>(elements); - aApm->push_back(fullRow); - elements = { 0.0, 1.0, 0.0 }; - fullRow = std::make_shared>(elements); - aApm->push_back(fullRow); - elements = { 0.0, 0.0, 1.0 }; - fullRow = std::make_shared>(elements); - aApm->push_back(fullRow); + aApm = std::make_shared>(ListListD{ + { 1, 0, 0 }, + { 0, 1, 0 }, + { 0, 0, 1 } + }); marker2->setaApm(aApm); assembly1->partFrame->addMarkerFrame(marker2); } @@ -79,34 +68,114 @@ int main() auto part1 = std::make_shared(); str = "Part1"; part1->setName(str); - elements = { 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }; - qX = std::make_shared>(elements); - elements = { 0.0, 0.0, 1.4248456266393e-10, 1.0 }; - qE = std::make_shared>(elements); + qX = std::make_shared>(ListD{ 0.38423366582893, 6.8384291794733e-9, -0.048029210642807 }); + qE = std::make_shared>(ListD{ 0.0, 0.0, 1.4248456266393e-10, 1.0 }); part1->setqX(qX); part1->setqE(qE); TheSystem.parts.push_back(part1); + { + auto marker1 = std::make_shared(); + str = "Marker1"; + marker1->setName(str); + rpmp = std::make_shared>(ListD{ -0.38423368514246, -2.6661567755108e-17, 0.048029210642807 }); + marker1->setrpmp(rpmp); + aApm = std::make_shared>(ListListD{ + { 1, 0, 0 }, + { 0, 1, 0 }, + { 0, 0, 1 } + }); + marker1->setaApm(aApm); + part1->partFrame->addMarkerFrame(marker1); + // + auto marker2 = std::make_shared(); + str = "Marker2"; + marker2->setName(str); + rpmp = std::make_shared>(ListD{ 0.38423368514246, -2.6661567755108e-17, 0.048029210642807 }); + marker2->setrpmp(rpmp); + aApm = std::make_shared>(ListListD{ + { 1, 0, 0 }, + { 0, 1, 0 }, + { 0, 0, 1 } + }); + marker2->setaApm(aApm); + part1->partFrame->addMarkerFrame(marker2); + } // auto part2 = std::make_shared(); str = "Part2"; part2->setName(str); - elements = { 0.38423366582893, 0.49215308269277, 0.048029210642807 }; - qX = std::make_shared>(elements); - elements = { 0.0, 0.0, 0.89871701272344, 0.4385290538168 }; - qE = std::make_shared>(elements); + qX = std::make_shared>(ListD{ 0.38423366582893, 0.49215308269277, 0.048029210642807 }); + qE = std::make_shared>(ListD{ 0.0, 0.0, 0.89871701272344, 0.4385290538168 }); part2->setqX(qX); part2->setqE(qE); TheSystem.parts.push_back(part2); + { + auto marker1 = std::make_shared(); + str = "Marker1"; + marker1->setName(str); + rpmp = std::make_shared>(ListD{ -0.6243797383565, 1.1997705489799e-16, -0.048029210642807 }); + marker1->setrpmp(rpmp); + aApm = std::make_shared>(ListListD{ + {1.0, 2.7755575615629e-16, 0.0}, + {-2.7755575615629e-16, 1.0, 0.0}, + {0.0, 0.0, 1.0} + }); + marker1->setaApm(aApm); + part2->partFrame->addMarkerFrame(marker1); + // + auto marker2 = std::make_shared(); + str = "Marker2"; + marker2->setName(str); + rpmp = std::make_shared>(ListD{ 0.6243797383565, -2.1329254204087e-16, -0.048029210642807 }); + marker2->setrpmp(rpmp); + aApm = std::make_shared>(ListListD{ + {1.0, 2.4980018054066e-16, 2.2204460492503e-16}, + {-2.4980018054066e-16, 1.0, 4.1633363423443e-17}, + {-2.2204460492503e-16, -4.1633363423443e-17, 1.0} + }); + marker2->setaApm(aApm); + part2->partFrame->addMarkerFrame(marker2); + } // auto part3 = std::make_shared(); str = "Part3"; part3->setName(str); - elements = { -1.284772285311e-18, 1.4645982581368, -4.788228906425e-17 }; - qX = std::make_shared>(elements); - elements = { 0.70710678118655, 0.70710678118655, 0.0, 0.0 }; - qE = std::make_shared>(elements); + qX = std::make_shared>(ListD{ -1.284772285311e-18, 1.4645982581368, -4.788228906425e-17 }); + qE = std::make_shared>(ListD{ 0.70710678118655, 0.70710678118655, 0.0, 0.0 }); part3->setqX(qX); part3->setqE(qE); TheSystem.parts.push_back(part3); + { + auto marker1 = std::make_shared(); + str = "Marker1"; + marker1->setName(str); + rpmp = std::make_shared>(ListD{ -0.48029210642807, 7.6201599718927e-18, -2.816737703896e-17 }); + marker1->setrpmp(rpmp); + aApm = std::make_shared>(ListListD{ + {9.2444637330587e-33, 1.0, 2.2204460492503e-16}, + {1.0, -9.2444637330587e-33, -1.0785207688569e-32}, + {-1.0785207688569e-32, 2.2204460492503e-16, -1.0} + }); + marker1->setaApm(aApm); + part3->partFrame->addMarkerFrame(marker1); + // + auto marker2 = std::make_shared(); + str = "Marker2"; + marker2->setName(str); + rpmp = std::make_shared>(ListD{ 0.48029210642807, 1.7618247880058e-17, 2.5155758471256e-17 }); + marker2->setrpmp(rpmp); + aApm = std::make_shared>(ListListD{ + {6.9388939039072e-18, -6.4146353042213e-50, 1.0}, + {1.0, -6.9388939039072e-18, 6.9388939039072e-18}, + {-6.9388939039072e-18, 1.0, -7.4837411882581e-50} + }); + marker2->setaApm(aApm); + part3->partFrame->addMarkerFrame(marker2); + } // + auto cylJoint4 = std::shared_ptr(); + auto revJoint3 = std::shared_ptr(); + auto revJoint2 = std::shared_ptr(); + auto revJoint1 = std::shared_ptr(); + auto rotMotion1 = std::shared_ptr(); } \ No newline at end of file diff --git a/MbDCode/MbDCode.vcxproj b/MbDCode/MbDCode.vcxproj index 65349fe..3dbf57b 100644 --- a/MbDCode/MbDCode.vcxproj +++ b/MbDCode/MbDCode.vcxproj @@ -131,6 +131,7 @@ + @@ -146,17 +147,25 @@ + + + + + + + + @@ -172,11 +181,18 @@ + + + + + + + diff --git a/MbDCode/MbDCode.vcxproj.filters b/MbDCode/MbDCode.vcxproj.filters index 63e0800..34fa30a 100644 --- a/MbDCode/MbDCode.vcxproj.filters +++ b/MbDCode/MbDCode.vcxproj.filters @@ -84,6 +84,33 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -155,5 +182,32 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/MbDCode/NewtonRaphson.h b/MbDCode/NewtonRaphson.h index 822fccc..e6b411a 100644 --- a/MbDCode/NewtonRaphson.h +++ b/MbDCode/NewtonRaphson.h @@ -1,8 +1,7 @@ #pragma once #include "Solver.h" namespace MbD { - class NewtonRaphson : - public Solver + class NewtonRaphson : public Solver { }; } diff --git a/MbDCode/PrescribedMotion.cpp b/MbDCode/PrescribedMotion.cpp new file mode 100644 index 0000000..45370a0 --- /dev/null +++ b/MbDCode/PrescribedMotion.cpp @@ -0,0 +1 @@ +#include "PrescribedMotion.h" diff --git a/MbDCode/PrescribedMotion.h b/MbDCode/PrescribedMotion.h new file mode 100644 index 0000000..ff112c3 --- /dev/null +++ b/MbDCode/PrescribedMotion.h @@ -0,0 +1,9 @@ +#pragma once +#include "Joint.h" + +namespace MbD { + class PrescribedMotion : public Joint + { + }; +} + diff --git a/MbDCode/RevoluteJoint.cpp b/MbDCode/RevoluteJoint.cpp new file mode 100644 index 0000000..1e728ca --- /dev/null +++ b/MbDCode/RevoluteJoint.cpp @@ -0,0 +1 @@ +#include "RevoluteJoint.h" diff --git a/MbDCode/RevoluteJoint.h b/MbDCode/RevoluteJoint.h new file mode 100644 index 0000000..e6b94ac --- /dev/null +++ b/MbDCode/RevoluteJoint.h @@ -0,0 +1,8 @@ +#pragma once +#include "Joint.h" +namespace MbD { + class RevoluteJoint : public Joint + { + }; +} + diff --git a/MbDCode/SparseColumn.cpp b/MbDCode/SparseColumn.cpp new file mode 100644 index 0000000..fd03a1b --- /dev/null +++ b/MbDCode/SparseColumn.cpp @@ -0,0 +1 @@ +#include "SparseColumn.h" diff --git a/MbDCode/SparseColumn.h b/MbDCode/SparseColumn.h new file mode 100644 index 0000000..11e7b6c --- /dev/null +++ b/MbDCode/SparseColumn.h @@ -0,0 +1,14 @@ +#pragma once +#include "SparseVector.h" + +namespace MbD { + template + class SparseColumn : public SparseVector + { + public: + SparseColumn() {} + SparseColumn(std::initializer_list> list) : SparseVector{ list } {} + SparseColumn(std::initializer_list> list) : SparseVector{ list } {} + }; +} + diff --git a/MbDCode/SparseMatrix.cpp b/MbDCode/SparseMatrix.cpp new file mode 100644 index 0000000..a598258 --- /dev/null +++ b/MbDCode/SparseMatrix.cpp @@ -0,0 +1 @@ +#include "SparseMatrix.h" diff --git a/MbDCode/SparseMatrix.h b/MbDCode/SparseMatrix.h new file mode 100644 index 0000000..eaf1303 --- /dev/null +++ b/MbDCode/SparseMatrix.h @@ -0,0 +1,22 @@ +#pragma once +#include "RowTypeMatrix.h" +#include "SparseRow.h" + +namespace MbD { + template + class SparseMatrix : public RowTypeMatrix>> + { + public: + SparseMatrix(std::initializer_list>> list2D) { + for (auto rowList : list2D) + { + auto row = std::make_shared>(rowList); + this->push_back(row); + } + } + }; +} + +typedef std::shared_ptr> SpMatDptr; +typedef std::initializer_list>> ListListPairD; + diff --git a/MbDCode/SparseRow.cpp b/MbDCode/SparseRow.cpp new file mode 100644 index 0000000..b296270 --- /dev/null +++ b/MbDCode/SparseRow.cpp @@ -0,0 +1 @@ +#include "SparseRow.h" diff --git a/MbDCode/SparseRow.h b/MbDCode/SparseRow.h new file mode 100644 index 0000000..58c3689 --- /dev/null +++ b/MbDCode/SparseRow.h @@ -0,0 +1,18 @@ +#pragma once +#include +#include + +#include "SparseVector.h" + +namespace MbD { + template + class SparseRow : public SparseVector + { + public: + SparseRow() {} + SparseRow(std::initializer_list> list) : SparseVector{ list } {} + SparseRow(std::initializer_list> list) : SparseVector{ list } {} + }; +} + +typedef std::shared_ptr> SpRowDptr; diff --git a/MbDCode/SparseVector.cpp b/MbDCode/SparseVector.cpp new file mode 100644 index 0000000..e6eb2e5 --- /dev/null +++ b/MbDCode/SparseVector.cpp @@ -0,0 +1 @@ +#include "SparseVector.h" diff --git a/MbDCode/SparseVector.h b/MbDCode/SparseVector.h new file mode 100644 index 0000000..43674fa --- /dev/null +++ b/MbDCode/SparseVector.h @@ -0,0 +1,27 @@ +#pragma once +#include +#include + +namespace MbD { + template + class SparseVector : public std::map + { + public: + SparseVector() {} + SparseVector(std::initializer_list> list) : std::map{ list } {} + SparseVector(std::initializer_list> list) { + for (auto pair : list) { + int i = 0; + int index; + T value; + for (auto element : pair) { + if (i == 0) index = (int)std::round(element); ; + if (i == 1) value = element; + i++; + } + this->insert(std::pair(index, value)); + } + } + }; +} + diff --git a/MbDCode/System.cpp b/MbDCode/System.cpp index 67d096b..2b8744e 100644 --- a/MbDCode/System.cpp +++ b/MbDCode/System.cpp @@ -10,4 +10,6 @@ MbD::System::System() { parts = std::vector>(); jointsMotions = std::vector>(); systemSolver = std::make_shared(*this); + //std::vector> parts; + //std::vector> jointsMotions; } diff --git a/MbDCode/System.h b/MbDCode/System.h index cbc3cca..a2257de 100644 --- a/MbDCode/System.h +++ b/MbDCode/System.h @@ -9,7 +9,9 @@ namespace MbD { class Part; + class Joint; class SystemSolver; + class System : public Item { //ToDo: Needed members admSystem namedItems mbdTime parts jointsMotions forcesTorques sensors variables hasChanged mbdSystemSolver diff --git a/MbDCode/Vector.h b/MbDCode/Vector.h index 302ca66..7bba73a 100644 --- a/MbDCode/Vector.h +++ b/MbDCode/Vector.h @@ -6,8 +6,10 @@ namespace MbD { class Vector : public Array { public: + Vector() {} Vector(int i) : Array(i) {} Vector(std::initializer_list list) : Array{ list } {} }; } +typedef std::initializer_list ListD; diff --git a/MbDCode/Vector.h.bak b/MbDCode/Vector.h.bak new file mode 100644 index 0000000..4932f6b --- /dev/null +++ b/MbDCode/Vector.h.bak @@ -0,0 +1,14 @@ +#pragma once +#include "Array.h" + +namespace MbD { + template + class Vector : public Array + { + public: + Vector() {} + Vector(int i) : Array(i) {} + Vector(std::initializer_list list) : Array{ list } {} + }; +} + diff --git a/MbDCode/ZRotation.cpp b/MbDCode/ZRotation.cpp new file mode 100644 index 0000000..7320bf0 --- /dev/null +++ b/MbDCode/ZRotation.cpp @@ -0,0 +1 @@ +#include "ZRotation.h" diff --git a/MbDCode/ZRotation.h b/MbDCode/ZRotation.h new file mode 100644 index 0000000..3d45fc6 --- /dev/null +++ b/MbDCode/ZRotation.h @@ -0,0 +1,9 @@ +#pragma once +#include "PrescribedMotion.h" + +namespace MbD { + class ZRotation : public PrescribedMotion + { + }; +} +