Switch to using built-in M_PI, even on MSVC (#68)
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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<Constant>(the1z);
|
||||
}
|
||||
else {
|
||||
eqctI->phiThePsiBlks->at(1) = std::make_shared<Constant>(OS_M_PI + the1z);
|
||||
eqctI->phiThePsiBlks->at(1) = std::make_shared<Constant>(M_PI + the1z);
|
||||
}
|
||||
eqctI->postInput();
|
||||
DirectionCosineConstraintIqctJqc::postInput();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* See LICENSE file for details about copyright. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "corecrt_math_defines.h"
|
||||
#include <cmath>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "corecrt_math_defines.h"
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ void MbD::MomentOfInertiaSolver::example1()
|
||||
|
||||
auto rpPp = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 1 });
|
||||
auto rotAxis = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 1 });
|
||||
auto aApP = std::make_shared<EulerParameters<double>>(rotAxis, OS_M_PI*10/180)->aA;
|
||||
auto aApP = std::make_shared<EulerParameters<double>>(rotAxis, M_PI*10/180)->aA;
|
||||
auto solver = std::make_shared<MomentOfInertiaSolver>();
|
||||
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<DiagonalMatrix<double>>();
|
||||
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);
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <cmath>
|
||||
#include "corecrt_math_defines.h"
|
||||
#include <stdexcept>
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* See LICENSE file for details about copyright. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "corecrt_math_defines.h"
|
||||
#include <cmath>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* See LICENSE file for details about copyright. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "corecrt_math_defines.h"
|
||||
#include <cmath>
|
||||
|
||||
#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<double>::min()) {
|
||||
aConstant = (2.0 * OS_M_PI * zIeJeIe->value()) - (thezIeJe->value() * pitch);
|
||||
aConstant = (2.0 * M_PI * zIeJeIe->value()) - (thezIeJe->value() * pitch);
|
||||
}
|
||||
ConstraintIJ::postInput();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* See LICENSE file for details about copyright. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "corecrt_math_defines.h"
|
||||
#include <cmath>
|
||||
|
||||
#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()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* See LICENSE file for details about copyright. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "corecrt_math_defines.h"
|
||||
#include <cmath>
|
||||
|
||||
#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));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* See LICENSE file for details about copyright. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "corecrt_math_defines.h"
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
@@ -339,7 +339,7 @@ bool MbD::SymbolicParser::constant()
|
||||
return true;
|
||||
}
|
||||
if (peekForTypevalue("word", "pi")) {
|
||||
auto symconst = std::make_shared<Constant>(OS_M_PI);
|
||||
auto symconst = std::make_shared<Constant>(M_PI);
|
||||
stack->push(symconst);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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 <math.h> 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
|
||||
Reference in New Issue
Block a user