diff --git a/.gitignore b/.gitignore index 774534a..6ead354 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,7 @@ .vs x64/ -*.bak \ No newline at end of file +*.bak + +cmake-build-debug +.idea diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..74cf91f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.26) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# add_library(some_target main.cpp) +add_executable(ondsel-solver MbDCode/MbDCode.cpp) +add_subdirectory(MbDCode) diff --git a/MbDCode/ASMTAssembly.cpp b/MbDCode/ASMTAssembly.cpp index af20a84..39418bc 100644 --- a/MbDCode/ASMTAssembly.cpp +++ b/MbDCode/ASMTAssembly.cpp @@ -30,9 +30,12 @@ using namespace MbD; -void MbD::ASMTAssembly::runFile(const char* chars) +void MbD::ASMTAssembly::runFile(const char* fileName) { - std::ifstream stream(chars); + std::ifstream stream(fileName); + if(stream.fail()) { + throw std::invalid_argument("File not found."); + } std::string line; std::vector lines; while (std::getline(stream, line)) { diff --git a/MbDCode/ASMTAssembly.h b/MbDCode/ASMTAssembly.h index e7bba63..219d4ef 100644 --- a/MbDCode/ASMTAssembly.h +++ b/MbDCode/ASMTAssembly.h @@ -33,7 +33,7 @@ namespace MbD { { // public: - static void runFile(const char* chars); + static void runFile(const char* fileName); ASMTAssembly* root() override; void parseASMT(std::vector& lines) override; void readNotes(std::vector& lines); diff --git a/MbDCode/AngleZIecJec.cpp b/MbDCode/AngleZIecJec.cpp index 443d225..dbaa8fd 100644 --- a/MbDCode/AngleZIecJec.cpp +++ b/MbDCode/AngleZIecJec.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include +#include "corecrt_math_defines.h" #include "AngleZIecJec.h" #include "Numeric.h" diff --git a/MbDCode/Array.h b/MbDCode/Array.h index aaa4ca0..808e366 100644 --- a/MbDCode/Array.h +++ b/MbDCode/Array.h @@ -29,7 +29,7 @@ namespace MbD { Array(std::vector vec) : std::vector(vec) {} Array(int count) : std::vector(count) {} Array(int count, const T& value) : std::vector(count, value) {} - Array(typename typename std::vector::iterator begin, typename typename std::vector::iterator end) : std::vector(begin, end) {} + Array(typename std::vector::iterator begin, typename std::vector::iterator end) : std::vector(begin, end) {} Array(std::initializer_list list) : std::vector{ list } {} virtual void initialize(); void copyFrom(std::shared_ptr> x); @@ -180,4 +180,4 @@ namespace MbD { { this->at(i) *= factor; } -} \ No newline at end of file +} diff --git a/MbDCode/CMakeLists.txt b/MbDCode/CMakeLists.txt new file mode 100644 index 0000000..85c099a --- /dev/null +++ b/MbDCode/CMakeLists.txt @@ -0,0 +1,268 @@ +target_sources(ondsel-solver PUBLIC + Abs.cpp + AbsConstraint.cpp + AccICKineNewtonRaphson.cpp + AccICNewtonRaphson.cpp + AccKineNewtonRaphson.cpp + AccNewtonRaphson.cpp + AngleJoint.cpp + AngleZIecJec.cpp + AngleZIeqcJec.cpp + AngleZIeqcJeqc.cpp + AnyGeneralSpline.cpp + AnyPosICNewtonRaphson.cpp + ArcTan.cpp + ArcTan2.cpp + Array.cpp + ASMTAnimationParameters.cpp + ASMTAssembly.cpp + ASMTConstantGravity.cpp + ASMTConstraintSet.cpp + ASMTCylindricalJoint.cpp + ASMTExtrusion.cpp + ASMTFixedJoint.cpp + ASMTForceTorque.cpp + ASMTGeneralMotion.cpp + ASMTItem.cpp + ASMTItemIJ.cpp + ASMTJoint.cpp + ASMTKinematicIJ.cpp + ASMTMarker.cpp + ASMTMotion.cpp + ASMTPart.cpp + ASMTPointInPlaneJoint.cpp + ASMTPrincipalMassMarker.cpp + ASMTRefCurve.cpp + ASMTRefItem.cpp + ASMTRefPoint.cpp + ASMTRefSurface.cpp + ASMTRevoluteJoint.cpp + ASMTRotationalMotion.cpp + ASMTSimulationParameters.cpp + ASMTSpatialContainer.cpp + ASMTSpatialItem.cpp + ASMTSphericalJoint.cpp + ASMTTime.cpp + ASMTTranslationalMotion.cpp + ASMTTranslationalJoint.cpp + ASMTUniversalJoint.cpp + AtPointConstraintIJ.cpp + AtPointConstraintIqcJc.cpp + AtPointConstraintIqcJqc.cpp + AtPointConstraintIqctJqc.cpp + AtPointJoint.cpp + BasicIntegrator.cpp + BasicQuasiIntegrator.cpp + BasicUserFunction.cpp + CADSystem.cpp + CartesianFrame.cpp + CompoundJoint.cpp + Constant.cpp + ConstantGravity.cpp + ConstantVelocityJoint.cpp + Constraint.cpp + ConstraintIJ.cpp + ConstVelConstraintIJ.cpp + ConstVelConstraintIqcJc.cpp + ConstVelConstraintIqcJqc.cpp + Cosine.cpp + CREATE.cpp + CylindricalJoint.cpp + CylSphJoint.cpp + DifferentiatedGeneralSpline.cpp + EndFrameqct2.cpp + EulerAngles.cpp + EulerAnglesDDot.cpp + EulerAnglesDot.cpp + Exponential.cpp + ExternalSystem.cpp + FunctionFromData.cpp + FunctionXcParameter.cpp + FunctionXY.cpp + GeneralSpline.cpp + Ln.cpp + Log10.cpp + LogN.cpp + Negative.cpp + PosVelAccData.cpp + DiagonalMatrix.cpp + DifferenceOperator.cpp + DirectionCosineConstraintIJ.cpp + DirectionCosineConstraintIqcJc.cpp + DirectionCosineConstraintIqcJqc.cpp + DirectionCosineConstraintIqctJqc.cpp + DirectionCosineIecJec.cpp + DirectionCosineIeqcJec.cpp + DirectionCosineIeqcJeqc.cpp + DirectionCosineIeqctJeqc.cpp + DiscontinuityError.cpp + DispCompIecJecIe.cpp + DispCompIecJecKec.cpp + DispCompIecJecKeqc.cpp + DispCompIecJecO.cpp + DispCompIeqcJecIe.cpp + DispCompIeqcJecKeqc.cpp + DispCompIeqcJecO.cpp + DispCompIeqcJeqcIe.cpp + DispCompIeqcJeqcKeqc.cpp + DispCompIeqcJeqcKeqct.cpp + DispCompIeqcJeqcO.cpp + DispCompIeqctJeqcIe.cpp + DispCompIeqctJeqcKeqct.cpp + DispCompIeqctJeqcO.cpp + DistanceConstraintIJ.cpp + DistanceConstraintIqcJc.cpp + DistanceConstraintIqcJqc.cpp + DistanceConstraintIqctJqc.cpp + DistancexyConstraintIJ.cpp + DistancexyConstraintIqcJc.cpp + DistancexyConstraintIqcJqc.cpp + DistIecJec.cpp + DistIeqcJec.cpp + DistIeqcJeqc.cpp + DistIeqctJeqc.cpp + DistxyIecJec.cpp + DistxyIeqcJec.cpp + DistxyIeqcJeqc.cpp + DistxyIeqctJeqc.cpp + EndFramec.cpp + EndFrameqc.cpp + EndFrameqct.cpp + EulerAngleszxz.cpp + EulerAngleszxzDDot.cpp + EulerAngleszxzDot.cpp + EulerArray.cpp + EulerConstraint.cpp + EulerParameters.cpp + EulerParametersDDot.cpp + EulerParametersDot.cpp + ExpressionX.cpp + FixedJoint.cpp + ForceTorqueData.cpp + ForceTorqueItem.cpp + FullColumn.cpp + FullMatrix.cpp + FullMotion.cpp + FullRow.cpp + Function.cpp + FunctionWithManyArgs.cpp + FunctionX.cpp + GearConstraintIJ.cpp + GearConstraintIqcJc.cpp + GearConstraintIqcJqc.cpp + GearJoint.cpp + GEFullMat.cpp + GEFullMatFullPv.cpp + GEFullMatParPv.cpp + GESpMat.cpp + GESpMatFullPv.cpp + GESpMatFullPvPosIC.cpp + GESpMatParPv.cpp + GESpMatParPvMarko.cpp + GESpMatParPvMarkoFast.cpp + GESpMatParPvPrecise.cpp + ICKineIntegrator.cpp + IndependentVariable.cpp + InLineJoint.cpp + InPlaneJoint.cpp + Integrator.cpp + IntegratorInterface.cpp + Item.cpp + Joint.cpp + KineIntegrator.cpp + KinematicIeJe.cpp + LDUFullMatParPv.cpp + LDUSpMat.cpp + LDUSpMatParPv.cpp + LDUSpMatParPvMarko.cpp + LDUSpMatParPvPrecise.cpp + LinearMultiStepMethod.cpp + LineInPlaneJoint.cpp + MarkerFrame.cpp + Math.cpp + MatrixDecomposition.cpp + MatrixGaussElimination.cpp + MatrixLDU.cpp + MatrixSolver.cpp + MaximumIterationError.cpp + NewtonRaphson.cpp + NewtonRaphsonError.cpp + NoRotationJoint.cpp + NotKinematicError.cpp + Numeric.cpp + OrbitAnglezIecJec.cpp + OrbitAnglezIeqcJec.cpp + OrbitAnglezIeqcJeqc.cpp + Orientation.cpp + ParallelAxesJoint.cpp + Part.cpp + PartFrame.cpp + PerpendicularJoint.cpp + PlanarJoint.cpp + PointInLineJoint.cpp + PointInPlaneJoint.cpp + PosICKineNewtonRaphson.cpp + PosICNewtonRaphson.cpp + PosKineNewtonRaphson.cpp + PosNewtonRaphson.cpp + Power.cpp + PrescribedMotion.cpp + Product.cpp + QuasiIntegrator.cpp + RackPinConstraintIJ.cpp + RackPinConstraintIqcJc.cpp + RackPinConstraintIqcJqc.cpp + RackPinJoint.cpp + Reciprocal.cpp + RedundantConstraint.cpp + RevCylJoint.cpp + RevoluteJoint.cpp + RowTypeMatrix.cpp + ScalarNewtonRaphson.cpp + ScrewConstraintIJ.cpp + ScrewConstraintIqcJc.cpp + ScrewConstraintIqcJqc.cpp + ScrewJoint.cpp + SimulationStoppingError.cpp + Sine.cpp + SingularMatrixError.cpp + Solver.cpp + SparseColumn.cpp + SparseMatrix.cpp + SparseRow.cpp + SparseVector.cpp + SphericalJoint.cpp + SphSphJoint.cpp + StableBackwardDifference.cpp + LDUFullMat.cpp + StateData.cpp + Sum.cpp + Symbolic.cpp + SymbolicParser.cpp + SyntaxError.cpp + System.cpp + SystemNewtonRaphson.cpp + SystemSolver.cpp + Time.cpp + TooManyTriesError.cpp + TooSmallStepSizeError.cpp + Translation.cpp + TranslationalJoint.cpp + TranslationConstraintIJ.cpp + TranslationConstraintIqcJc.cpp + TranslationConstraintIqcJqc.cpp + TranslationConstraintIqctJqc.cpp + Units.cpp + UniversalJoint.cpp + UserFunction.cpp + Variable.cpp + FullVector.cpp + VectorNewtonRaphson.cpp + VelICKineSolver.cpp + VelICSolver.cpp + VelKineSolver.cpp + VelSolver.cpp + ZRotation.cpp + ZTranslation.cpp + ASMTAssembly.cpp +) diff --git a/MbDCode/CREATE.h b/MbDCode/CREATE.h index 8afb8a3..67bdf9a 100644 --- a/MbDCode/CREATE.h +++ b/MbDCode/CREATE.h @@ -71,15 +71,15 @@ namespace MbD { static std::shared_ptr ConstraintWith(std::shared_ptr frmi, std::shared_ptr frmj, int axis) { std::shared_ptr inst; std::string str = typeid(T(frmi, frmj, axis)).name(); - if (str == "class MbD::AtPointConstraintIJ") { + if (str.find("AtPointConstraintIJ") != std::string::npos) { if (std::dynamic_pointer_cast(frmi)) { inst = std::make_shared(frmi, frmj, axis); } else { inst = std::make_shared(frmi, frmj, axis); } - } - else if(str == "class MbD::TranslationConstraintIJ") { + } // "class MbD::Tran + else if(str.find("TranslationConstraintIJ") != std::string::npos) { if (std::dynamic_pointer_cast(frmi)) { inst = std::make_shared(frmi, frmj, axis); } @@ -98,7 +98,7 @@ namespace MbD { static std::shared_ptr ConstraintWith(std::shared_ptr frmi, std::shared_ptr frmj, int axisi, int axisj) { std::shared_ptr inst; std::string str = typeid(T(frmi, frmj, axisi, axisj)).name(); - if (str == "class MbD::DirectionCosineConstraintIJ") { + if (str.find("DirectionCosineConstraintIJ") != std::string::npos) { if (std::dynamic_pointer_cast(frmi)) { inst = std::make_shared(frmi, frmj, axisi, axisj); } diff --git a/MbDCode/FullMatrix.h b/MbDCode/FullMatrix.h index fd792a7..0b2817e 100644 --- a/MbDCode/FullMatrix.h +++ b/MbDCode/FullMatrix.h @@ -8,7 +8,7 @@ #pragma once -#include +#include "corecrt_math_defines.h" #include #include "RowTypeMatrix.h" @@ -296,6 +296,13 @@ namespace MbD { row2->atiput(2, 0.0); return rotMat; } + template<> + inline void FullMatrix::zeroSelf() + { + for (int i = 0; i < this->size(); i++) { + this->at(i)->zeroSelf(); + } + } template<> inline void FullMatrix::identity() { this->zeroSelf(); @@ -452,13 +459,6 @@ namespace MbD { assert(false); return 0.0; } - template<> - inline void FullMatrix::zeroSelf() - { - for (int i = 0; i < this->size(); i++) { - this->at(i)->zeroSelf(); - } - } template inline void FullMatrix::zeroSelf() { diff --git a/MbDCode/FullRow.h b/MbDCode/FullRow.h index 2ed2052..b4df0bd 100644 --- a/MbDCode/FullRow.h +++ b/MbDCode/FullRow.h @@ -35,7 +35,7 @@ namespace MbD { FullRow(std::vector vec) : FullVector(vec) {} FullRow(int count) : FullVector(count) {} FullRow(int count, const T& value) : FullVector(count, value) {} - FullRow(typename std::vector::iterator begin, typename std::vector::iterator end) : FullVector(begin, end) {} + FullRow(typename std::vector::const_iterator begin, typename std::vector::const_iterator end) : FullVector(begin, end) {} FullRow(std::initializer_list list) : FullVector{ list } {} FRowsptr times(T a); FRowsptr negated(); diff --git a/MbDCode/FullVector.h b/MbDCode/FullVector.h index 0216460..8959c2b 100644 --- a/MbDCode/FullVector.h +++ b/MbDCode/FullVector.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include "Array.h" diff --git a/MbDCode/GESpMatFullPv.cpp b/MbDCode/GESpMatFullPv.cpp index dc81fda..ff30ba3 100644 --- a/MbDCode/GESpMatFullPv.cpp +++ b/MbDCode/GESpMatFullPv.cpp @@ -108,6 +108,12 @@ void GESpMatFullPv::backSubstituteIntoDU() double sum, duij, duii; //answerX = rightHandSideB->copyEmpty(); assert(m == n); + + // TODO: temp +// assert(n > 0); +// auto localLen = colOrder->numberOfElements(); +// assert(n < localLen); + answerX = std::make_shared>(m); auto jn = colOrder->at(n); answerX->at(jn) = rightHandSideB->at(m) / matrixA->at(m)->at(jn); diff --git a/MbDCode/GearConstraintIJ.h b/MbDCode/GearConstraintIJ.h index 4092d59..7ffd8b7 100644 --- a/MbDCode/GearConstraintIJ.h +++ b/MbDCode/GearConstraintIJ.h @@ -9,7 +9,7 @@ #pragma once #include "ConstraintIJ.h" -#include "OrbitAngleZIecJec.h" +#include "OrbitAnglezIecJec.h" namespace MbD { class GearConstraintIJ : public ConstraintIJ diff --git a/MbDCode/GearConstraintIqcJc.cpp b/MbDCode/GearConstraintIqcJc.cpp index dd01774..cd348ff 100644 --- a/MbDCode/GearConstraintIqcJc.cpp +++ b/MbDCode/GearConstraintIqcJc.cpp @@ -9,7 +9,7 @@ #include "GearConstraintIqcJc.h" #include "EndFrameqc.h" #include "CREATE.h" -#include "OrbitAngleZIeqcJec.h" +#include "OrbitAnglezIeqcJec.h" using namespace MbD; diff --git a/MbDCode/GearConstraintIqcJqc.cpp b/MbDCode/GearConstraintIqcJqc.cpp index 0793ed6..717c815 100644 --- a/MbDCode/GearConstraintIqcJqc.cpp +++ b/MbDCode/GearConstraintIqcJqc.cpp @@ -8,7 +8,7 @@ #include "GearConstraintIqcJqc.h" #include "EndFrameqc.h" -#include "OrbitAngleZIeqcJeqc.h" +#include "OrbitAnglezIeqcJeqc.h" #include "CREATE.h" using namespace MbD; diff --git a/MbDCode/Item.cpp b/MbDCode/Item.cpp index e20f225..820b2e6 100644 --- a/MbDCode/Item.cpp +++ b/MbDCode/Item.cpp @@ -6,9 +6,9 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include +//#include #include -#include +//#include #include #include "Item.h" diff --git a/MbDCode/MbDCode.cpp b/MbDCode/MbDCode.cpp index 710feb8..4adb2f3 100644 --- a/MbDCode/MbDCode.cpp +++ b/MbDCode/MbDCode.cpp @@ -26,20 +26,20 @@ void runSpMat(); int main() { - //ASMTAssembly::runFile("piston.asmt"); - //ASMTAssembly::runFile("00backhoe.asmt"); - //ASMTAssembly::runFile("circular.asmt"); + ASMTAssembly::runFile("piston.asmt"); + ASMTAssembly::runFile("00backhoe.asmt"); + ASMTAssembly::runFile("circular.asmt"); //ASMTAssembly::runFile("cirpendu.asmt"); //Under constrained. Testing ICKine. - //ASMTAssembly::runFile("engine1.asmt"); - //ASMTAssembly::runFile("fourbar.asmt"); - //ASMTAssembly::runFile("fourbot.asmt"); - //ASMTAssembly::runFile("wobpump.asmt"); + ASMTAssembly::runFile("engine1.asmt"); + ASMTAssembly::runFile("fourbar.asmt"); + ASMTAssembly::runFile("fourbot.asmt"); + ASMTAssembly::runFile("wobpump.asmt"); auto cadSystem = std::make_shared(); cadSystem->runOndselDoublePendulum(); - ////cadSystem->runOndselPiston(); - //cadSystem->runPiston(); - //runSpMat(); + cadSystem->runOndselPiston(); + cadSystem->runPiston(); + runSpMat(); } void runSpMat() { @@ -58,4 +58,4 @@ void runSpMat() { auto matSolver = CREATE::With(); auto answer = matSolver->solvewithsaveOriginal(spMat, fullCol, true); auto aAx = spMat->timesFullColumn(answer); -} \ No newline at end of file +} diff --git a/MbDCode/Numeric.cpp b/MbDCode/Numeric.cpp index e78ee3c..b1fc9a2 100644 --- a/MbDCode/Numeric.cpp +++ b/MbDCode/Numeric.cpp @@ -7,7 +7,7 @@ ***************************************************************************/ #include -#include +#include "corecrt_math_defines.h" #include #include "Numeric.h" diff --git a/MbDCode/OrbitAnglezIecJec.cpp b/MbDCode/OrbitAnglezIecJec.cpp index c53166e..3a1ec8b 100644 --- a/MbDCode/OrbitAnglezIecJec.cpp +++ b/MbDCode/OrbitAnglezIecJec.cpp @@ -6,9 +6,9 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include +#include "corecrt_math_defines.h" -#include "OrbitAngleZIecJec.h" +#include "OrbitAnglezIecJec.h" #include "Numeric.h" using namespace MbD; diff --git a/MbDCode/OrbitAnglezIeqcJec.cpp b/MbDCode/OrbitAnglezIeqcJec.cpp index 1dd5298..b9bb400 100644 --- a/MbDCode/OrbitAnglezIeqcJec.cpp +++ b/MbDCode/OrbitAnglezIeqcJec.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include "OrbitAngleZIeqcJec.h" +#include "OrbitAnglezIeqcJec.h" #include "CREATE.h" #include "DispCompIeqcJecIe.h" diff --git a/MbDCode/OrbitAnglezIeqcJec.h b/MbDCode/OrbitAnglezIeqcJec.h index 65610f3..2788bad 100644 --- a/MbDCode/OrbitAnglezIeqcJec.h +++ b/MbDCode/OrbitAnglezIeqcJec.h @@ -8,7 +8,7 @@ #pragma once -#include "OrbitAngleZIecJec.h" +#include "OrbitAnglezIecJec.h" namespace MbD { class OrbitAngleZIeqcJec : public OrbitAngleZIecJec diff --git a/MbDCode/OrbitAnglezIeqcJeqc.cpp b/MbDCode/OrbitAnglezIeqcJeqc.cpp index 79709c6..b8e689c 100644 --- a/MbDCode/OrbitAnglezIeqcJeqc.cpp +++ b/MbDCode/OrbitAnglezIeqcJeqc.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include "OrbitAngleZIeqcJeqc.h" +#include "OrbitAnglezIeqcJeqc.h" #include "CREATE.h" #include "DispCompIeqcJeqcIe.h" diff --git a/MbDCode/OrbitAnglezIeqcJeqc.h b/MbDCode/OrbitAnglezIeqcJeqc.h index ec0f843..8455372 100644 --- a/MbDCode/OrbitAnglezIeqcJeqc.h +++ b/MbDCode/OrbitAnglezIeqcJeqc.h @@ -8,7 +8,7 @@ #pragma once -#include "OrbitAngleZIeqcJec.h" +#include "OrbitAnglezIeqcJec.h" namespace MbD { class OrbitAngleZIeqcJeqc : public OrbitAngleZIeqcJec diff --git a/MbDCode/PosICNewtonRaphson.cpp b/MbDCode/PosICNewtonRaphson.cpp index 1f84e4a..b894656 100644 --- a/MbDCode/PosICNewtonRaphson.cpp +++ b/MbDCode/PosICNewtonRaphson.cpp @@ -103,13 +103,13 @@ void PosICNewtonRaphson::handleSingularMatrix() } else { std::string str = typeid(*matrixSolver).name(); - if (str == "class GESpMatParPvMarkoFast") { + if (str.find("GESpMatParPvMarkoFast") != std::string::npos) { matrixSolver = CREATE::With(); this->solveEquations(); } else { str = typeid(*matrixSolver).name(); - if (str == "class GESpMatParPvPrecise") { + if (str.find("GESpMatParPvPrecise") != std::string::npos) { this->lookForRedundantConstraints(); matrixSolver = this->matrixSolverClassNew(); } diff --git a/MbDCode/ScrewConstraintIJ.cpp b/MbDCode/ScrewConstraintIJ.cpp index c63e537..cbfd4e7 100644 --- a/MbDCode/ScrewConstraintIJ.cpp +++ b/MbDCode/ScrewConstraintIJ.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include +#include "corecrt_math_defines.h" #include "ScrewConstraintIJ.h" diff --git a/MbDCode/ScrewConstraintIqcJc.cpp b/MbDCode/ScrewConstraintIqcJc.cpp index 74cb241..463954f 100644 --- a/MbDCode/ScrewConstraintIqcJc.cpp +++ b/MbDCode/ScrewConstraintIqcJc.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include +#include "corecrt_math_defines.h" #include "ScrewConstraintIqcJc.h" #include "EndFrameqc.h" diff --git a/MbDCode/ScrewConstraintIqcJqc.cpp b/MbDCode/ScrewConstraintIqcJqc.cpp index 1ee6649..e02d7fe 100644 --- a/MbDCode/ScrewConstraintIqcJqc.cpp +++ b/MbDCode/ScrewConstraintIqcJqc.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include +#include "corecrt_math_defines.h" #include "ScrewConstraintIqcJqc.h" #include "EndFrameqc.h" diff --git a/MbDCode/SymbolicParser.cpp b/MbDCode/SymbolicParser.cpp index ed54b44..ca0c160 100644 --- a/MbDCode/SymbolicParser.cpp +++ b/MbDCode/SymbolicParser.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include +#include "corecrt_math_defines.h" #include #include diff --git a/MbDCode/SystemNewtonRaphson.cpp b/MbDCode/SystemNewtonRaphson.cpp index 47d813a..d569297 100644 --- a/MbDCode/SystemNewtonRaphson.cpp +++ b/MbDCode/SystemNewtonRaphson.cpp @@ -52,13 +52,13 @@ void SystemNewtonRaphson::basicSolveEquations() void SystemNewtonRaphson::handleSingularMatrix() { std::string str = typeid(*matrixSolver).name(); - if (str == "class GESpMatParPvMarkoFast") { + if (str.find("GESpMatParPvMarkoFast") != std::string::npos) { matrixSolver = CREATE::With(); this->solveEquations(); } else { str = typeid(*matrixSolver).name(); - if (str == "class GESpMatParPvPrecise") { + if (str.find("GESpMatParPvPrecise") != std::string::npos) { str = "MbD: Singular Matrix Error. "; system->logString(str); matrixSolver = this->matrixSolverClassNew(); diff --git a/MbDCode/VelSolver.cpp b/MbDCode/VelSolver.cpp index b4be203..e85d4db 100644 --- a/MbDCode/VelSolver.cpp +++ b/MbDCode/VelSolver.cpp @@ -25,13 +25,13 @@ void VelSolver::basicSolveEquations() void VelSolver::handleSingularMatrix() { std::string str = typeid(*matrixSolver).name(); - if (str == "class GESpMatParPvMarkoFast") { + if (str.find("GESpMatParPvMarkoFast") != std::string::npos) { matrixSolver = CREATE::With(); this->solveEquations(); } else { str = typeid(*matrixSolver).name(); - if (str == "class GESpMatParPvPrecise") { + if (str.find("GESpMatParPvPrecise") != std::string::npos) { this->logSingularMatrixMessage(); matrixSolver = this->matrixSolverClassNew(); } diff --git a/MbDCode/corecrt_math_defines.h b/MbDCode/corecrt_math_defines.h new file mode 100644 index 0000000..d8c0560 --- /dev/null +++ b/MbDCode/corecrt_math_defines.h @@ -0,0 +1,30 @@ +// +// corecrt_math_defines.h +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// Definitions of useful mathematical constants +// +#pragma once + +#ifndef _MATH_DEFINES_DEFINED +#define _MATH_DEFINES_DEFINED +// Definitions of useful mathematical constants +// +// Define _USE_MATH_DEFINES before including to expose these macro +// definitions for common math constants. These are placed under an #ifdef +// since these commonly-defined names are not part of the C or C++ standards +// #define M_E 2.71828182845904523536 // e +// #define M_LOG2E 1.44269504088896340736 // log2(e) +// #define M_LOG10E 0.434294481903251827651 // log10(e) +// #define M_LN2 0.693147180559945309417 // ln(2) +// #define M_LN10 2.30258509299404568402 // ln(10) +#define M_PI 3.14159265358979323846 // pi +// #define M_PI_2 1.57079632679489661923 // pi/2 +// #define M_PI_4 0.785398163397448309616 // pi/4 +// #define M_1_PI 0.318309886183790671538 // 1/pi +// #define M_2_PI 0.636619772367581343076 // 2/pi +#define M_2_SQRTPI 1.12837916709551257390 // 2/sqrt(pi) +#define M_SQRT2 1.41421356237309504880 // sqrt(2) +// #define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2) +#endif \ No newline at end of file