diff --git a/CMakeLists.txt b/CMakeLists.txt index 0885a00..0d77f39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -438,7 +438,6 @@ set(ONDSELSOLVER_HEADERS OndselSolver/ConstVelConstraintIJ.h OndselSolver/ConstVelConstraintIqcJc.h OndselSolver/ConstVelConstraintIqcJqc.h - OndselSolver/corecrt_math_defines.h OndselSolver/Cosine.h OndselSolver/CREATE.h OndselSolver/CylindricalJoint.h @@ -662,6 +661,10 @@ set_target_properties(OndselSolver PUBLIC_HEADER "${ONDSELSOLVER_HEADERS}" ) +if(MSVC) + target_compile_definitions(OndselSolver PRIVATE _USE_MATH_DEFINES) +endif(MSVC) + configure_file(OndselSolver.pc.in ${CMAKE_BINARY_DIR}/OndselSolver.pc @ONLY) install(TARGETS OndselSolver LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/OndselSolver/AllowZRotationConstraintIqctJqc.cpp b/OndselSolver/AllowZRotationConstraintIqctJqc.cpp index c87aeba..3918e20 100644 --- a/OndselSolver/AllowZRotationConstraintIqctJqc.cpp +++ b/OndselSolver/AllowZRotationConstraintIqctJqc.cpp @@ -37,11 +37,11 @@ void MbD::AllowZRotationConstraintIqctJqc::postInput() auto aEulerAngleszxz = aAImJe->eulerAngleszxz(); auto the1z = aEulerAngleszxz->at(1); auto the2x = aEulerAngleszxz->at(2); - if (std::abs(the2x) < (OS_M_PI / 2.0)) { + if (std::abs(the2x) < (M_PI / 2.0)) { eqctI->phiThePsiBlks->at(1) = std::make_shared(the1z); } else { - eqctI->phiThePsiBlks->at(1) = std::make_shared(OS_M_PI + the1z); + eqctI->phiThePsiBlks->at(1) = std::make_shared(M_PI + the1z); } eqctI->postInput(); DirectionCosineConstraintIqctJqc::postInput(); diff --git a/OndselSolver/AngleZIecJec.cpp b/OndselSolver/AngleZIecJec.cpp index e426bf0..bb544c7 100644 --- a/OndselSolver/AngleZIecJec.cpp +++ b/OndselSolver/AngleZIecJec.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include "corecrt_math_defines.h" +#include #include "AngleZIecJec.h" #include "Numeric.h" @@ -30,7 +30,7 @@ void MbD::AngleZIecJec::calcPostDynCorrectorIteration() auto diffOfSquares = sthez * sthez - (cthez * cthez); auto sumOfSquaresSquared = sumOfSquares * sumOfSquares; auto thez0to2pi = Numeric::arcTan0to2piYoverX(sthez, cthez); - thez = std::round((thez - thez0to2pi) / (2.0 * OS_M_PI)) * (2.0 * OS_M_PI) + thez0to2pi; + thez = std::round((thez - thez0to2pi) / (2.0 * M_PI)) * (2.0 * M_PI) + thez0to2pi; //std::cout << "AngleZIecJec thez = " << thez << std::endl; cosOverSSq = cthez / sumOfSquares; diff --git a/OndselSolver/FullMatrix.h b/OndselSolver/FullMatrix.h index 693f92b..1013791 100644 --- a/OndselSolver/FullMatrix.h +++ b/OndselSolver/FullMatrix.h @@ -8,7 +8,7 @@ #pragma once -#include "corecrt_math_defines.h" +#include #include #include "RowTypeMatrix.h" @@ -641,12 +641,12 @@ namespace MbD { if (std::abs(sthe1y) > 0.9999) { if (sthe1y > 0.0) { the0x = std::atan2(this->at(1)->at(0), this->at(1)->at(1)); - the1y = OS_M_PI / 2.0; + the1y = M_PI / 2.0; the2z = 0.0; } else { the0x = std::atan2(this->at(2)->at(1), this->at(2)->at(0)); - the1y = OS_M_PI / -2.0; + the1y = M_PI / -2.0; the2z = 0.0; } } @@ -682,7 +682,7 @@ namespace MbD { the2z = 0.0; } else { - the1x = OS_M_PI; + the1x = M_PI; the2z = 0.0; } } diff --git a/OndselSolver/MomentOfInertiaSolver.cpp b/OndselSolver/MomentOfInertiaSolver.cpp index b887616..522222f 100644 --- a/OndselSolver/MomentOfInertiaSolver.cpp +++ b/OndselSolver/MomentOfInertiaSolver.cpp @@ -15,7 +15,7 @@ void MbD::MomentOfInertiaSolver::example1() auto rpPp = std::make_shared>(ListD{ 0, 0, 1 }); auto rotAxis = std::make_shared>(ListD{ 0, 0, 1 }); - auto aApP = std::make_shared>(rotAxis, OS_M_PI*10/180)->aA; + auto aApP = std::make_shared>(rotAxis, M_PI*10/180)->aA; auto solver = std::make_shared(); solver->setm(4.0); solver->setJPP(aJpp); @@ -350,7 +350,7 @@ void MbD::MomentOfInertiaSolver::calcJppFromFullJcmP() auto q = (c + (2.0 * aDiv3 * aDiv3 * aDiv3) - (aDiv3 * b)) / 2.0; auto phiDiv3 = modifiedArcCos(-q / std::sqrt(-p * p * p)) / 3.0; auto twoSqrtMinusp = 2.0 * std::sqrt(-p); - auto piDiv3 = OS_M_PI / 3.0; + auto piDiv3 = M_PI / 3.0; auto sortedJ = std::make_shared>(); sortedJ->push_back(twoSqrtMinusp * std::cos(phiDiv3)); sortedJ->push_back(twoSqrtMinusp * -std::cos(phiDiv3 + piDiv3)); @@ -392,7 +392,7 @@ double MbD::MomentOfInertiaSolver::modifiedArcCos(double val) } else { if (val < -1.0) { - return OS_M_PI; + return M_PI; } else { return std::acos(val); diff --git a/OndselSolver/Numeric.cpp b/OndselSolver/Numeric.cpp index 1c82d5f..3c345b7 100644 --- a/OndselSolver/Numeric.cpp +++ b/OndselSolver/Numeric.cpp @@ -7,7 +7,6 @@ ***************************************************************************/ #include -#include "corecrt_math_defines.h" #include #include "Numeric.h" @@ -25,7 +24,7 @@ double MbD::Numeric::arcTan0to2piYoverX(double y, double x) } else { //"Third and forth quadrants." - return 2.0 * OS_M_PI + std::atan2(y, x); + return 2.0 * M_PI + std::atan2(y, x); } } diff --git a/OndselSolver/OrbitAngleZIecJec.cpp b/OndselSolver/OrbitAngleZIecJec.cpp index d35dd22..d6f2ec9 100644 --- a/OndselSolver/OrbitAngleZIecJec.cpp +++ b/OndselSolver/OrbitAngleZIecJec.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include "corecrt_math_defines.h" +#include #include "OrbitAngleZIecJec.h" #include "Numeric.h" @@ -29,7 +29,7 @@ void MbD::OrbitAngleZIecJec::calcPostDynCorrectorIteration() auto diffOfSquares = y * y - (x * x); auto sumOfSquaresSquared = sumOfSquares * sumOfSquares; auto thez0to2pi = Numeric::arcTan0to2piYoverX(y, x); - thez = std::round((thez - thez0to2pi) / (2.0 * OS_M_PI)) * (2.0 * OS_M_PI) + thez0to2pi; + thez = std::round((thez - thez0to2pi) / (2.0 * M_PI)) * (2.0 * M_PI) + thez0to2pi; cosOverSSq = x / sumOfSquares; sinOverSSq = y / sumOfSquares; twoCosSinOverSSqSq = 2.0 * x * y / sumOfSquaresSquared; diff --git a/OndselSolver/ScrewConstraintIJ.cpp b/OndselSolver/ScrewConstraintIJ.cpp index 04e7617..ab3c314 100644 --- a/OndselSolver/ScrewConstraintIJ.cpp +++ b/OndselSolver/ScrewConstraintIJ.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include "corecrt_math_defines.h" +#include #include "ScrewConstraintIJ.h" #include "ScrewConstraintIqcJqc.h" @@ -32,7 +32,7 @@ void MbD::ScrewConstraintIJ::calcPostDynCorrectorIteration() { auto z = zIeJeIe->value(); auto thez = thezIeJe->thez; - aG = (2.0 * OS_M_PI * z) - (pitch * thez) - aConstant; + aG = (2.0 * M_PI * z) - (pitch * thez) - aConstant; } void MbD::ScrewConstraintIJ::init_zthez() @@ -73,7 +73,7 @@ void MbD::ScrewConstraintIJ::postInput() zIeJeIe->postInput(); thezIeJe->postInput(); if (aConstant == std::numeric_limits::min()) { - aConstant = (2.0 * OS_M_PI * zIeJeIe->value()) - (thezIeJe->value() * pitch); + aConstant = (2.0 * M_PI * zIeJeIe->value()) - (thezIeJe->value() * pitch); } ConstraintIJ::postInput(); } diff --git a/OndselSolver/ScrewConstraintIqcJc.cpp b/OndselSolver/ScrewConstraintIqcJc.cpp index d5ae620..9933eb4 100644 --- a/OndselSolver/ScrewConstraintIqcJc.cpp +++ b/OndselSolver/ScrewConstraintIqcJc.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include "corecrt_math_defines.h" +#include #include "ScrewConstraintIqcJc.h" #include "EndFrameqc.h" @@ -59,23 +59,23 @@ void MbD::ScrewConstraintIqcJc::addToJointTorqueI(FColDsptr jointTorque) void MbD::ScrewConstraintIqcJc::calc_pGpEI() { - pGpEI = zIeJeIe->pvaluepEI()->times(2.0 * OS_M_PI)->minusFullRow(thezIeJe->pvaluepEI()->times(pitch)); + pGpEI = zIeJeIe->pvaluepEI()->times(2.0 * M_PI)->minusFullRow(thezIeJe->pvaluepEI()->times(pitch)); } void MbD::ScrewConstraintIqcJc::calc_pGpXI() { - pGpXI = zIeJeIe->pvaluepXI()->times(2.0 * OS_M_PI); + pGpXI = zIeJeIe->pvaluepXI()->times(2.0 * M_PI); } void MbD::ScrewConstraintIqcJc::calc_ppGpEIpEI() { - ppGpEIpEI = zIeJeIe->ppvaluepEIpEI()->times(2.0 * OS_M_PI) + ppGpEIpEI = zIeJeIe->ppvaluepEIpEI()->times(2.0 * M_PI) ->minusFullMatrix(thezIeJe->ppvaluepEIpEI()->times(pitch)); } void MbD::ScrewConstraintIqcJc::calc_ppGpXIpEI() { - ppGpXIpEI = zIeJeIe->ppvaluepXIpEI()->times(2.0 * OS_M_PI); + ppGpXIpEI = zIeJeIe->ppvaluepXIpEI()->times(2.0 * M_PI); } void MbD::ScrewConstraintIqcJc::calcPostDynCorrectorIteration() diff --git a/OndselSolver/ScrewConstraintIqcJqc.cpp b/OndselSolver/ScrewConstraintIqcJqc.cpp index 5564020..0551f60 100644 --- a/OndselSolver/ScrewConstraintIqcJqc.cpp +++ b/OndselSolver/ScrewConstraintIqcJqc.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include "corecrt_math_defines.h" +#include #include "ScrewConstraintIqcJqc.h" #include "EndFrameqc.h" @@ -37,28 +37,28 @@ void MbD::ScrewConstraintIqcJqc::initthezIeJe() void MbD::ScrewConstraintIqcJqc::calc_pGpEJ() { - pGpEJ = zIeJeIe->pvaluepEJ()->times(2.0 * OS_M_PI)->minusFullRow(thezIeJe->pvaluepEJ()->times(pitch)); + pGpEJ = zIeJeIe->pvaluepEJ()->times(2.0 * M_PI)->minusFullRow(thezIeJe->pvaluepEJ()->times(pitch)); } void MbD::ScrewConstraintIqcJqc::calc_pGpXJ() { - pGpXJ = zIeJeIe->pvaluepXJ()->times(2.0 * OS_M_PI); + pGpXJ = zIeJeIe->pvaluepXJ()->times(2.0 * M_PI); } void MbD::ScrewConstraintIqcJqc::calc_ppGpEIpEJ() { - ppGpEIpEJ = zIeJeIe->ppvaluepEIpEJ()->times(2.0 * OS_M_PI) + ppGpEIpEJ = zIeJeIe->ppvaluepEIpEJ()->times(2.0 * M_PI) ->minusFullMatrix(thezIeJe->ppvaluepEIpEJ()->times(pitch)); } void MbD::ScrewConstraintIqcJqc::calc_ppGpEIpXJ() { - ppGpEIpXJ = zIeJeIe->ppvaluepEIpXJ()->times(2.0 * OS_M_PI); + ppGpEIpXJ = zIeJeIe->ppvaluepEIpXJ()->times(2.0 * M_PI); } void MbD::ScrewConstraintIqcJqc::calc_ppGpEJpEJ() { - ppGpEJpEJ = zIeJeIe->ppvaluepEJpEJ()->times(2.0 * OS_M_PI) + ppGpEJpEJ = zIeJeIe->ppvaluepEJpEJ()->times(2.0 * M_PI) ->minusFullMatrix(thezIeJe->ppvaluepEJpEJ()->times(pitch)); } diff --git a/OndselSolver/SymbolicParser.cpp b/OndselSolver/SymbolicParser.cpp index 76f9ac4..0aacf4a 100644 --- a/OndselSolver/SymbolicParser.cpp +++ b/OndselSolver/SymbolicParser.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include "corecrt_math_defines.h" +#include #include #include #include @@ -339,7 +339,7 @@ bool MbD::SymbolicParser::constant() return true; } if (peekForTypevalue("word", "pi")) { - auto symconst = std::make_shared(OS_M_PI); + auto symconst = std::make_shared(M_PI); stack->push(symconst); return true; } diff --git a/OndselSolver/corecrt_math_defines.h b/OndselSolver/corecrt_math_defines.h deleted file mode 100644 index 0ae075c..0000000 --- a/OndselSolver/corecrt_math_defines.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// 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 OS_M_PI 3.14159265358979323846264338327950288 // 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 OS_M_2_SQRTPI 1.12837916709551257389615890312154517 // 2/sqrt(pi) -#define OS_M_SQRT2 1.41421356237309504880168872420969808 // sqrt(2) -// #define M_SQRT1_2 0.707106781186547524401 // 1/sqrt(2) -#endif \ No newline at end of file