Sketcher: Use std::numeric_limits and std::numbers instead of defines
This commit is contained in:
@@ -3060,6 +3060,7 @@ int Sketch::addAngleAtPointConstraint(int geoId1,
|
||||
ConstraintType cTyp,
|
||||
bool driving)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
if (!(cTyp == Angle || cTyp == Tangent || cTyp == Perpendicular)) {
|
||||
// assert(0);//none of the three types. Why are we here??
|
||||
return -1;
|
||||
@@ -3132,28 +3133,28 @@ int Sketch::addAngleAtPointConstraint(int geoId1,
|
||||
// the desired angle value (and we are to decide if 180* should be added to it)
|
||||
double angleDesire = 0.0;
|
||||
if (cTyp == Tangent) {
|
||||
angleOffset = -M_PI / 2;
|
||||
angleOffset = -pi / 2;
|
||||
angleDesire = 0.0;
|
||||
}
|
||||
if (cTyp == Perpendicular) {
|
||||
angleOffset = 0;
|
||||
angleDesire = M_PI / 2;
|
||||
angleDesire = pi / 2;
|
||||
}
|
||||
|
||||
if (*value
|
||||
== 0.0) { // autodetect tangency internal/external (and same for perpendicularity)
|
||||
double angleErr = GCSsys.calculateAngleViaPoint(*crv1, *crv2, p) - angleDesire;
|
||||
// bring angleErr to -pi..pi
|
||||
if (angleErr > M_PI) {
|
||||
angleErr -= M_PI * 2;
|
||||
if (angleErr > pi) {
|
||||
angleErr -= pi * 2;
|
||||
}
|
||||
if (angleErr < -M_PI) {
|
||||
angleErr += M_PI * 2;
|
||||
if (angleErr < -pi) {
|
||||
angleErr += pi * 2;
|
||||
}
|
||||
|
||||
// the autodetector
|
||||
if (fabs(angleErr) > M_PI / 2) {
|
||||
angleDesire += M_PI;
|
||||
if (fabs(angleErr) > pi / 2) {
|
||||
angleDesire += pi;
|
||||
}
|
||||
|
||||
*angle = angleDesire;
|
||||
@@ -4542,7 +4543,7 @@ bool Sketch::updateNonDrivingConstraints()
|
||||
}
|
||||
else if ((*it).constr->Type == Angle) {
|
||||
|
||||
(*it).constr->setValue(std::fmod(*((*it).value), 2.0 * M_PI));
|
||||
(*it).constr->setValue(std::fmod(*((*it).value), 2.0 * std::numbers::pi));
|
||||
}
|
||||
else if ((*it).constr->Type == Diameter && (*it).constr->First >= 0) {
|
||||
|
||||
|
||||
@@ -591,7 +591,7 @@ void SketchAnalysis::analyseMissingPointOnPointCoincident(double angleprecision)
|
||||
if (fabs(tgv1 * tgv2) > fabs(cos(angleprecision))) {
|
||||
vc.Type = Sketcher::Tangent;
|
||||
}
|
||||
else if (fabs(tgv1 * tgv2) < fabs(cos(M_PI / 2 - angleprecision))) {
|
||||
else if (fabs(tgv1 * tgv2) < fabs(cos(std::numbers::pi / 2 - angleprecision))) {
|
||||
vc.Type = Sketcher::Perpendicular;
|
||||
}
|
||||
}
|
||||
@@ -726,7 +726,8 @@ void SketchAnalysis::makeMissingVerticalHorizontalOneByOne()
|
||||
|
||||
bool SketchAnalysis::checkVertical(Base::Vector3d dir, double angleprecision)
|
||||
{
|
||||
return (dir.x == 0. && dir.y != 0.) || (fabs(dir.y / dir.x) > tan(M_PI / 2 - angleprecision));
|
||||
return (dir.x == 0. && dir.y != 0.)
|
||||
|| (fabs(dir.y / dir.x) > tan(std::numbers::pi / 2 - angleprecision));
|
||||
}
|
||||
|
||||
bool SketchAnalysis::checkHorizontal(Base::Vector3d dir, double angleprecision)
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
int detectMissingPointOnPointConstraints(double precision = Precision::Confusion() * 1000,
|
||||
bool includeconstruction = true);
|
||||
/// Point on Point constraint simple routine Analyse step (see constructor)
|
||||
void analyseMissingPointOnPointCoincident(double angleprecision = M_PI / 8);
|
||||
void analyseMissingPointOnPointCoincident(double angleprecision = std::numbers::pi / 8);
|
||||
/// Point on Point constraint simple routine Get step (see constructor)
|
||||
std::vector<ConstraintIds>& getMissingPointOnPointConstraints()
|
||||
{
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
void makeMissingPointOnPointCoincidentOneByOne();
|
||||
|
||||
/// Vertical/Horizontal constraints simple routine Detect step (see constructor)
|
||||
int detectMissingVerticalHorizontalConstraints(double angleprecision = M_PI / 8);
|
||||
int detectMissingVerticalHorizontalConstraints(double angleprecision = std::numbers::pi / 8);
|
||||
/// Vertical/Horizontal constraints simple routine Get step (see constructor)
|
||||
std::vector<ConstraintIds>& getMissingVerticalHorizontalConstraints()
|
||||
{
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
///
|
||||
/// It applies coincidents - vertical/horizontal constraints and equality constraints.
|
||||
int autoconstraint(double precision = Precision::Confusion() * 1000,
|
||||
double angleprecision = M_PI / 8,
|
||||
double angleprecision = std::numbers::pi / 8,
|
||||
bool includeconstruction = true);
|
||||
|
||||
// helper functions, which may be used by more complex methods, and/or called directly by user
|
||||
|
||||
@@ -1143,7 +1143,7 @@ void SketchObject::reverseAngleConstraintToSupplementary(Constraint* constr, int
|
||||
}
|
||||
else {
|
||||
double actAngle = constr->getValue();
|
||||
constr->setValue(M_PI - actAngle);
|
||||
constr->setValue(std::numbers::pi - actAngle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3248,12 +3248,12 @@ int SketchObject::fillet(int GeoId1, int GeoId2, const Base::Vector3d& refPnt1,
|
||||
std::swap(startAngle, endAngle);
|
||||
}
|
||||
|
||||
if (endAngle > 2 * M_PI) {
|
||||
endAngle -= 2 * M_PI;
|
||||
if (endAngle > 2 * std::numbers::pi) {
|
||||
endAngle -= 2 * std::numbers::pi;
|
||||
}
|
||||
|
||||
if (startAngle < 0) {
|
||||
endAngle += 2 * M_PI;
|
||||
endAngle += 2 * std::numbers::pi;
|
||||
}
|
||||
|
||||
// Create Arc Segment
|
||||
@@ -4905,6 +4905,8 @@ std::vector<Part::Geometry*> SketchObject::getSymmetric(const std::vector<int>&
|
||||
int refGeoId,
|
||||
Sketcher::PointPos refPosId)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
std::vector<Part::Geometry*> symmetricVals;
|
||||
bool refIsLine = refPosId == Sketcher::PointPos::none;
|
||||
int cgeoid = getHighestCurveIndex() + 1;
|
||||
@@ -4980,8 +4982,8 @@ std::vector<Part::Geometry*> SketchObject::getSymmetric(const std::vector<int>&
|
||||
Base::Vector3d scp =
|
||||
cp + 2.0 * (cp.Perpendicular(refGeoLine->getStartPoint(), vectline) - cp);
|
||||
|
||||
double theta1 = Base::fmod(atan2(sep.y - scp.y, sep.x - scp.x), 2.f * M_PI);
|
||||
double theta2 = Base::fmod(atan2(ssp.y - scp.y, ssp.x - scp.x), 2.f * M_PI);
|
||||
double theta1 = Base::fmod(atan2(sep.y - scp.y, sep.x - scp.x), 2.f * std::numbers::pi);
|
||||
double theta2 = Base::fmod(atan2(ssp.y - scp.y, ssp.x - scp.x), 2.f * std::numbers::pi);
|
||||
|
||||
geoaoc->setCenter(scp);
|
||||
geoaoc->setRange(theta1, theta2, true);
|
||||
@@ -5028,12 +5030,12 @@ std::vector<Part::Geometry*> SketchObject::getSymmetric(const std::vector<int>&
|
||||
|
||||
double theta1, theta2;
|
||||
geosymaoe->getRange(theta1, theta2, true);
|
||||
theta1 = 2.0 * M_PI - theta1;
|
||||
theta2 = 2.0 * M_PI - theta2;
|
||||
theta1 = 2.0 * pi - theta1;
|
||||
theta2 = 2.0 * pi - theta2;
|
||||
std::swap(theta1, theta2);
|
||||
if (theta1 < 0) {
|
||||
theta1 += 2.0 * M_PI;
|
||||
theta2 += 2.0 * M_PI;
|
||||
theta1 += 2.0 * pi;
|
||||
theta2 += 2.0 * pi;
|
||||
}
|
||||
|
||||
geosymaoe->setRange(theta1, theta2, true);
|
||||
@@ -5178,8 +5180,8 @@ std::vector<Part::Geometry*> SketchObject::getSymmetric(const std::vector<int>&
|
||||
Base::Vector3d sep = ep + 2.0 * (refpoint - ep);
|
||||
Base::Vector3d scp = cp + 2.0 * (refpoint - cp);
|
||||
|
||||
double theta1 = Base::fmod(atan2(ssp.y - scp.y, ssp.x - scp.x), 2.f * M_PI);
|
||||
double theta2 = Base::fmod(atan2(sep.y - scp.y, sep.x - scp.x), 2.f * M_PI);
|
||||
double theta1 = Base::fmod(atan2(ssp.y - scp.y, ssp.x - scp.x), 2.f * pi);
|
||||
double theta2 = Base::fmod(atan2(sep.y - scp.y, sep.x - scp.x), 2.f * pi);
|
||||
|
||||
geoaoc->setCenter(scp);
|
||||
geoaoc->setRange(theta1, theta2, true);
|
||||
@@ -8568,6 +8570,8 @@ void processEdge(const TopoDS_Edge& edge,
|
||||
gp_Ax3& sketchAx3,
|
||||
TopoDS_Shape& aProjFace)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
BRepAdaptor_Curve curve(edge);
|
||||
if (curve.GetType() == GeomAbs_Line) {
|
||||
geos.emplace_back(projectLine(curve, gPlane, invPlm));
|
||||
@@ -8641,11 +8645,11 @@ void processEdge(const TopoDS_Edge& edge,
|
||||
int tours = 0;
|
||||
double startAngle = baseAngle + alpha;
|
||||
// bring startAngle back in [-pi/2 , 3pi/2[
|
||||
while (startAngle < -M_PI / 2.0 && tours < 10) {
|
||||
startAngle = baseAngle + ++tours * 2.0 * M_PI + alpha;
|
||||
while (startAngle < -pi / 2.0 && tours < 10) {
|
||||
startAngle = baseAngle + ++tours * 2.0 * pi + alpha;
|
||||
}
|
||||
while (startAngle >= 3.0 * M_PI / 2.0 && tours > -10) {
|
||||
startAngle = baseAngle + --tours * 2.0 * M_PI + alpha;
|
||||
while (startAngle >= 3.0 * pi / 2.0 && tours > -10) {
|
||||
startAngle = baseAngle + --tours * 2.0 * pi + alpha;
|
||||
}
|
||||
|
||||
// apply same offset to end angle
|
||||
@@ -8661,7 +8665,7 @@ void processEdge(const TopoDS_Edge& edge,
|
||||
// P2 = P2 already defined
|
||||
P1 = ProjPointOnPlane_XYZ(beg, sketchPlane);
|
||||
}
|
||||
else if (endAngle < M_PI) {
|
||||
else if (endAngle < pi) {
|
||||
// P2 = P2, already defined
|
||||
P1 = ProjPointOnPlane_XYZ(end, sketchPlane);
|
||||
}
|
||||
@@ -8671,16 +8675,16 @@ void processEdge(const TopoDS_Edge& edge,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (startAngle < M_PI) {
|
||||
if (endAngle < M_PI) {
|
||||
else if (startAngle < pi) {
|
||||
if (endAngle < pi) {
|
||||
P1 = ProjPointOnPlane_XYZ(beg, sketchPlane);
|
||||
P2 = ProjPointOnPlane_XYZ(end, sketchPlane);
|
||||
}
|
||||
else if (endAngle < 2.0 * M_PI - startAngle) {
|
||||
else if (endAngle < 2.0 * pi - startAngle) {
|
||||
P2 = ProjPointOnPlane_XYZ(beg, sketchPlane);
|
||||
// P1 = P1, already defined
|
||||
}
|
||||
else if (endAngle < 2.0 * M_PI) {
|
||||
else if (endAngle < 2.0 * pi) {
|
||||
P2 = ProjPointOnPlane_XYZ(end, sketchPlane);
|
||||
// P1 = P1, already defined
|
||||
}
|
||||
@@ -8690,15 +8694,15 @@ void processEdge(const TopoDS_Edge& edge,
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (endAngle < 2 * M_PI) {
|
||||
if (endAngle < 2 * pi) {
|
||||
P1 = ProjPointOnPlane_XYZ(beg, sketchPlane);
|
||||
P2 = ProjPointOnPlane_XYZ(end, sketchPlane);
|
||||
}
|
||||
else if (endAngle < 4 * M_PI - startAngle) {
|
||||
else if (endAngle < 4 * pi - startAngle) {
|
||||
P1 = ProjPointOnPlane_XYZ(beg, sketchPlane);
|
||||
// P2 = P2, already defined
|
||||
}
|
||||
else if (endAngle < 3 * M_PI) {
|
||||
else if (endAngle < 3 * pi) {
|
||||
// P1 = P1, already defined
|
||||
P2 = ProjPointOnPlane_XYZ(end, sketchPlane);
|
||||
}
|
||||
@@ -8818,7 +8822,7 @@ void processEdge(const TopoDS_Edge& edge,
|
||||
gp_Vec2d PB = ProjVecOnPlane_UV(origAxisMinor, sketchPlane);
|
||||
double t_max = 2.0 * PA.Dot(PB) / (PA.SquareMagnitude() - PB.SquareMagnitude());
|
||||
t_max = 0.5 * atan(t_max);// gives new major axis is most cases, but not all
|
||||
double t_min = t_max + 0.5 * M_PI;
|
||||
double t_min = t_max + 0.5 * pi;
|
||||
|
||||
// ON_max = OM(t_max) gives the point, which projected on the sketch plane,
|
||||
// becomes the apoapse of the projected ellipse.
|
||||
@@ -9313,7 +9317,7 @@ void SketchObject::rebuildExternalGeometry(std::optional<ExternalToAdd> extToAdd
|
||||
processEdge(edge, geos, gPlane, invPlm, mov, sketchPlane, invRot, sketchAx3, aProjFace);
|
||||
}
|
||||
|
||||
if (fabs(dnormal.Angle(snormal) - M_PI_2) < Precision::Confusion()) {
|
||||
if (fabs(dnormal.Angle(snormal) - std::numbers::pi/2) < Precision::Confusion()) {
|
||||
// The face is normal to the sketch plane
|
||||
// We don't want to keep the projection of all the edges of the face.
|
||||
// We need a single line that goes from min to max of all the projections.
|
||||
@@ -11310,6 +11314,8 @@ int SketchObject::port_reversedExternalArcs(bool justAnalyze)
|
||||
/// false - fail (this indicates an error, or that a constraint locking isn't supported).
|
||||
bool SketchObject::AutoLockTangencyAndPerpty(Constraint* cstr, bool bForce, bool bLock)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
try {
|
||||
// assert ( cstr->Type == Tangent || cstr->Type == Perpendicular);
|
||||
/*tangency type already set. If not bForce - don't touch.*/
|
||||
@@ -11359,25 +11365,25 @@ bool SketchObject::AutoLockTangencyAndPerpty(Constraint* cstr, bool bForce, bool
|
||||
// the desired angle value (and we are to decide if 180* should be added to it)
|
||||
double angleDesire = 0.0;
|
||||
if (cstr->Type == Tangent) {
|
||||
angleOffset = -M_PI / 2;
|
||||
angleOffset = -pi / 2;
|
||||
angleDesire = 0.0;
|
||||
}
|
||||
if (cstr->Type == Perpendicular) {
|
||||
angleOffset = 0;
|
||||
angleDesire = M_PI / 2;
|
||||
angleDesire = pi / 2;
|
||||
}
|
||||
|
||||
double angleErr = calculateAngleViaPoint(geoId1, geoId2, p.x, p.y) - angleDesire;
|
||||
|
||||
// bring angleErr to -pi..pi
|
||||
if (angleErr > M_PI)
|
||||
angleErr -= M_PI * 2;
|
||||
if (angleErr < -M_PI)
|
||||
angleErr += M_PI * 2;
|
||||
if (angleErr > pi)
|
||||
angleErr -= pi * 2;
|
||||
if (angleErr < -pi)
|
||||
angleErr += pi * 2;
|
||||
|
||||
// the autodetector
|
||||
if (fabs(angleErr) > M_PI / 2)
|
||||
angleDesire += M_PI;
|
||||
if (fabs(angleErr) > pi / 2)
|
||||
angleDesire += pi;
|
||||
|
||||
// external tangency. The angle stored is offset by Pi/2 so that a value of 0.0 is
|
||||
// invalid and treated as "undecided".
|
||||
|
||||
@@ -841,13 +841,13 @@ public:
|
||||
public:
|
||||
// Analyser functions
|
||||
int autoConstraint(double precision = Precision::Confusion() * 1000,
|
||||
double angleprecision = M_PI / 20,
|
||||
double angleprecision = std::numbers::pi / 20,
|
||||
bool includeconstruction = true);
|
||||
|
||||
int detectMissingPointOnPointConstraints(double precision = Precision::Confusion() * 1000,
|
||||
bool includeconstruction = true);
|
||||
void analyseMissingPointOnPointCoincident(double angleprecision = M_PI / 8);
|
||||
int detectMissingVerticalHorizontalConstraints(double angleprecision = M_PI / 8);
|
||||
void analyseMissingPointOnPointCoincident(double angleprecision = std::numbers::pi / 8);
|
||||
int detectMissingVerticalHorizontalConstraints(double angleprecision = std::numbers::pi / 8);
|
||||
int detectMissingEqualityConstraints(double precision);
|
||||
|
||||
std::vector<ConstraintIds>& getMissingPointOnPointConstraints();
|
||||
|
||||
@@ -1918,7 +1918,7 @@ PyObject* SketchObjectPy::insertBSplineKnot(PyObject* args)
|
||||
PyObject* SketchObjectPy::autoconstraint(PyObject* args)
|
||||
{
|
||||
double precision = Precision::Confusion() * 1000;
|
||||
double angleprecision = M_PI / 8;
|
||||
double angleprecision = std::numbers::pi / 8;
|
||||
PyObject* includeconstruction = Py_True;
|
||||
|
||||
|
||||
@@ -1960,7 +1960,7 @@ PyObject* SketchObjectPy::detectMissingPointOnPointConstraints(PyObject* args)
|
||||
|
||||
PyObject* SketchObjectPy::detectMissingVerticalHorizontalConstraints(PyObject* args)
|
||||
{
|
||||
double angleprecision = M_PI / 8;
|
||||
double angleprecision = std::numbers::pi / 8;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|d", &angleprecision)) {
|
||||
return nullptr;
|
||||
@@ -1984,7 +1984,7 @@ PyObject* SketchObjectPy::detectMissingEqualityConstraints(PyObject* args)
|
||||
|
||||
PyObject* SketchObjectPy::analyseMissingPointOnPointCoincident(PyObject* args)
|
||||
{
|
||||
double angleprecision = M_PI / 8;
|
||||
double angleprecision = std::numbers::pi / 8;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|d", &angleprecision)) {
|
||||
return nullptr;
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#pragma warning(disable : 4251)
|
||||
#endif
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
#include <algorithm>
|
||||
#define DEBUG_DERIVS 0
|
||||
@@ -864,6 +864,8 @@ double ConstraintP2PAngle::grad(double* param)
|
||||
|
||||
double ConstraintP2PAngle::maxStep(MAP_pD_D& dir, double lim)
|
||||
{
|
||||
constexpr double pi_18 = std::numbers::pi / 18;
|
||||
|
||||
MAP_pD_D::iterator it = dir.find(angle());
|
||||
if (it != dir.end()) {
|
||||
double step = std::abs(it->second);
|
||||
@@ -1444,6 +1446,8 @@ double ConstraintL2LAngle::grad(double* param)
|
||||
|
||||
double ConstraintL2LAngle::maxStep(MAP_pD_D& dir, double lim)
|
||||
{
|
||||
constexpr double pi_18 = std::numbers::pi / 18;
|
||||
|
||||
MAP_pD_D::iterator it = dir.find(angle());
|
||||
if (it != dir.end()) {
|
||||
double step = std::abs(it->second);
|
||||
@@ -3536,10 +3540,10 @@ void ConstraintArcLength::errorgrad(double* err, double* grad, double* param)
|
||||
double startA = *arc.startAngle;
|
||||
// Assume positive angles and CCW arc
|
||||
while (startA < 0.) {
|
||||
startA += 2. * M_PI;
|
||||
startA += 2. * std::numbers::pi;
|
||||
}
|
||||
while (endA < startA) {
|
||||
endA += 2. * M_PI;
|
||||
endA += 2. * std::numbers::pi;
|
||||
}
|
||||
if (err) {
|
||||
*err = rad * (endA - startA) - *distance();
|
||||
|
||||
@@ -47,10 +47,10 @@
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <cfloat>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <numbers>
|
||||
|
||||
#include "GCS.h"
|
||||
#include "qp_eq.h"
|
||||
@@ -1029,6 +1029,8 @@ int System::addConstraintPerpendicularLine2Arc(Point& p1,
|
||||
int tagId,
|
||||
bool driving)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
addConstraintP2PCoincident(p2, a.start, tagId, driving);
|
||||
double dx = *(p2.x) - *(p1.x);
|
||||
double dy = *(p2.y) - *(p1.y);
|
||||
@@ -1046,6 +1048,8 @@ int System::addConstraintPerpendicularArc2Line(Arc& a,
|
||||
int tagId,
|
||||
bool driving)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
addConstraintP2PCoincident(p1, a.end, tagId, driving);
|
||||
double dx = *(p2.x) - *(p1.x);
|
||||
double dy = *(p2.y) - *(p1.y);
|
||||
@@ -1063,8 +1067,10 @@ int System::addConstraintPerpendicularCircle2Arc(Point& center,
|
||||
int tagId,
|
||||
bool driving)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
addConstraintP2PDistance(a.start, center, radius, tagId, driving);
|
||||
double incrAngle = *(a.startAngle) < *(a.endAngle) ? pi_2 : -pi_2;
|
||||
double incrAngle = *(a.startAngle) < *(a.endAngle) ? pi / 2 : -pi / 2;
|
||||
double tangAngle = *a.startAngle + incrAngle;
|
||||
double dx = *(a.start.x) - *(center.x);
|
||||
double dy = *(a.start.y) - *(center.y);
|
||||
@@ -1082,8 +1088,10 @@ int System::addConstraintPerpendicularArc2Circle(Arc& a,
|
||||
int tagId,
|
||||
bool driving)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
addConstraintP2PDistance(a.end, center, radius, tagId, driving);
|
||||
double incrAngle = *(a.startAngle) < *(a.endAngle) ? -pi_2 : pi_2;
|
||||
double incrAngle = *(a.startAngle) < *(a.endAngle) ? -pi / 2 : pi / 2;
|
||||
double tangAngle = *a.endAngle + incrAngle;
|
||||
double dx = *(a.end.x) - *(center.x);
|
||||
double dy = *(a.end.y) - *(center.y);
|
||||
@@ -2270,12 +2278,13 @@ int System::solve_LM(SubSystem* subsys, bool isRedundantsolving)
|
||||
x_new = x + h;
|
||||
h_norm = h.squaredNorm();
|
||||
|
||||
constexpr double epsilon = std::numeric_limits<double>::epsilon();
|
||||
if (h_norm <= eps1 * eps1 * x.norm()) {
|
||||
// relative change in p is small, stop
|
||||
stop = 3;
|
||||
break;
|
||||
}
|
||||
else if (h_norm >= (x.norm() + eps1) / (DBL_EPSILON * DBL_EPSILON)) {
|
||||
else if (h_norm >= (x.norm() + eps1) / (epsilon * epsilon)) {
|
||||
// almost singular
|
||||
stop = 4;
|
||||
break;
|
||||
|
||||
@@ -53,9 +53,6 @@ public:
|
||||
};
|
||||
|
||||
using VEC_P = std::vector<Point>;
|
||||
static constexpr double pi = boost::math::constants::pi<double>();
|
||||
static constexpr double pi_2 = pi / 2.0;
|
||||
static constexpr double pi_18 = pi / 18.0;
|
||||
|
||||
/// Class DeriVector2 holds a vector value and its derivative on the
|
||||
/// parameter that the derivatives are being calculated for now. x,y is the
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#ifndef _PreComp_
|
||||
#include <Precision.hxx>
|
||||
#include <QPainter>
|
||||
#include <cfloat>
|
||||
#endif
|
||||
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
@@ -114,10 +113,10 @@ void finishDatumConstraint(Gui::Command* cmd,
|
||||
|
||||
if (lastConstraintType == Radius || lastConstraintType == Diameter) {
|
||||
labelPosition = hGrp->GetFloat("RadiusDiameterConstraintDisplayBaseAngle", 15.0)
|
||||
* (M_PI / 180);// Get radius/diameter constraint display angle
|
||||
* (std::numbers::pi / 180);// Get radius/diameter constraint display angle
|
||||
labelPositionRandomness =
|
||||
hGrp->GetFloat("RadiusDiameterConstraintDisplayAngleRandomness", 0.0)
|
||||
* (M_PI / 180);// Get randomness
|
||||
* (std::numbers::pi / 180);// Get randomness
|
||||
|
||||
// Adds a random value around the base angle, so that possibly overlapping labels get likely
|
||||
// a different position.
|
||||
@@ -320,7 +319,7 @@ bool SketcherGui::calculateAngle(Sketcher::SketchObject* Obj, int& GeoId1, int&
|
||||
}
|
||||
else {
|
||||
// if all points are collinear
|
||||
double length = DBL_MAX;
|
||||
double length = std::numeric_limits<double>::max();
|
||||
for (int i = 0; i <= 1; i++) {
|
||||
for (int j = 0; j <= 1; j++) {
|
||||
double tmp = Base::DistanceP2(p2[j], p1[i]);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#ifndef _PreComp_
|
||||
#include <Inventor/SbString.h>
|
||||
#include <QApplication>
|
||||
#include <cfloat>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#ifndef _PreComp_
|
||||
#include <Inventor/SbString.h>
|
||||
#include <QApplication>
|
||||
#include <cfloat>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <cfloat>
|
||||
#include <memory>
|
||||
|
||||
#include <QApplication>
|
||||
@@ -1205,6 +1204,8 @@ public:
|
||||
|
||||
void mouseMove(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
if (Mode == STATUS_SEEK_First) {
|
||||
|
||||
if (QApplication::keyboardModifiers() == Qt::ControlModifier)
|
||||
@@ -1218,14 +1219,14 @@ public:
|
||||
Base::Vector2d endpoint = onSketchPos;
|
||||
|
||||
if (snapMode == SnapMode::Snap5Degree) {
|
||||
angle = round(angle / (M_PI / 36)) * M_PI / 36;
|
||||
angle = round(angle / (pi / 36)) * pi / 36;
|
||||
endpoint = EditCurve[0] + length * Base::Vector2d(cos(angle), sin(angle));
|
||||
}
|
||||
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string lengthString = lengthToDisplayFormat(length, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / M_PI, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / pi, 1);
|
||||
text.sprintf(" (%s, %s)", lengthString.c_str(), angleString.c_str());
|
||||
setPositionText(endpoint, text);
|
||||
}
|
||||
@@ -1781,6 +1782,8 @@ public:
|
||||
|
||||
void mouseMove(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
if (Mode == STATUS_SEEK_First) {
|
||||
|
||||
if (QApplication::keyboardModifiers() == Qt::ControlModifier)
|
||||
@@ -1794,14 +1797,14 @@ public:
|
||||
Base::Vector2d endpoint = onSketchPos;
|
||||
|
||||
if (snapMode == SnapMode::Snap5Degree) {
|
||||
angle = round(angle / (M_PI / 36)) * M_PI / 36;
|
||||
angle = round(angle / (pi / 36)) * pi / 36;
|
||||
endpoint = EditCurve[0] + length * Base::Vector2d(cos(angle), sin(angle));
|
||||
}
|
||||
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string lengthString = lengthToDisplayFormat(length, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / M_PI, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / pi, 1);
|
||||
text.sprintf(" (%s, %s)", lengthString.c_str(), angleString.c_str());
|
||||
setPositionText(endpoint, text);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <cfloat>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
|
||||
@@ -425,6 +425,8 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
const Base::Vector2d& Dir,
|
||||
AutoConstraint::TargetType type)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
suggestedConstraints.clear();
|
||||
SketchObject* obj = sketchgui->getSketchObject();
|
||||
|
||||
@@ -550,18 +552,18 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
|
||||
// Number of Degree of deviation from horizontal or vertical lines
|
||||
const double angleDev = 2;
|
||||
const double angleDevRad = angleDev * M_PI / 180.;
|
||||
const double angleDevRad = angleDev * pi / 180.;
|
||||
|
||||
AutoConstraint constr;
|
||||
constr.Type = Sketcher::None;
|
||||
constr.GeoId = GeoEnum::GeoUndef;
|
||||
constr.PosId = PointPos::none;
|
||||
double angle = std::abs(atan2(Dir.y, Dir.x));
|
||||
if (angle < angleDevRad || (M_PI - angle) < angleDevRad) {
|
||||
if (angle < angleDevRad || (pi - angle) < angleDevRad) {
|
||||
// Suggest horizontal constraint
|
||||
constr.Type = Sketcher::Horizontal;
|
||||
}
|
||||
else if (std::abs(angle - M_PI_2) < angleDevRad) {
|
||||
else if (std::abs(angle - pi / 2) < angleDevRad) {
|
||||
// Suggest vertical constraint
|
||||
constr.Type = Sketcher::Vertical;
|
||||
}
|
||||
@@ -665,7 +667,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
|
||||
double angle = atan2(projPnt.y, projPnt.x);
|
||||
while (angle < startAngle) {
|
||||
angle += 2 * D_PI; // Bring it to range of arc
|
||||
angle += 2 * pi; // Bring it to range of arc
|
||||
}
|
||||
|
||||
// if the point is on correct side of arc
|
||||
@@ -714,10 +716,10 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
aoe->getMinorRadius()
|
||||
* ((tmpPos.x - center.x) * majdir.x + (tmpPos.y - center.y) * majdir.y))
|
||||
- startAngle,
|
||||
2.f * M_PI);
|
||||
2.f * pi);
|
||||
|
||||
while (angle < startAngle) {
|
||||
angle += 2 * D_PI; // Bring it to range of arc
|
||||
angle += 2 * pi; // Bring it to range of arc
|
||||
}
|
||||
|
||||
// if the point is on correct side of arc
|
||||
@@ -978,7 +980,7 @@ void DrawSketchHandler::drawDirectionAtCursor(const Base::Vector2d& position,
|
||||
|
||||
SbString text;
|
||||
std::string lengthString = lengthToDisplayFormat(length, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / M_PI, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / std::numbers::pi, 1);
|
||||
text.sprintf(" (%s, %s)", lengthString.c_str(), angleString.c_str());
|
||||
setPositionText(position, text);
|
||||
}
|
||||
@@ -1009,7 +1011,7 @@ void DrawSketchHandler::drawDoubleAtCursor(const Base::Vector2d& position,
|
||||
SbString text;
|
||||
std::string doubleString = unit == Base::Unit::Length
|
||||
? lengthToDisplayFormat(val, 1)
|
||||
: angleToDisplayFormat(val * 180.0 / M_PI, 1);
|
||||
: angleToDisplayFormat(val * 180.0 / std::numbers::pi, 1);
|
||||
text.sprintf(" (%s)", doubleString.c_str());
|
||||
setPositionText(position, text);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ private:
|
||||
if (constructionMethod() == ConstructionMethod::Center) {
|
||||
secondPoint = onSketchPos;
|
||||
double angle1 = (onSketchPos - centerPoint).Angle() - startAngle;
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI;
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * std::numbers::pi;
|
||||
arcAngle = abs(angle1 - arcAngle) < abs(angle2 - arcAngle) ? angle1 : angle2;
|
||||
|
||||
if (arcAngle > 0) {
|
||||
@@ -183,7 +183,7 @@ private:
|
||||
}
|
||||
startAngle = std::max(angle1, angle2);
|
||||
endAngle = std::min(angle1, angle2);
|
||||
arcAngle = 2 * M_PI - (startAngle - endAngle);
|
||||
arcAngle = 2 * std::numbers::pi - (startAngle - endAngle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ void DSHArcControllerBase::doEnforceControlParameters(Base::Vector2d& onSketchPo
|
||||
if (onViewParameters[OnViewParameter::Fifth]->isSet) {
|
||||
double arcAngle =
|
||||
Base::toRadians(onViewParameters[OnViewParameter::Fifth]->getValue());
|
||||
if (fmod(fabs(arcAngle), 2 * M_PI) < Precision::Confusion()) {
|
||||
if (fmod(fabs(arcAngle), 2 * std::numbers::pi) < Precision::Confusion()) {
|
||||
unsetOnViewParameter(onViewParameters[OnViewParameter::Fifth].get());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@ public:
|
||||
|
||||
void mouseMove(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
if (Mode == STATUS_SEEK_First) {
|
||||
setPositionText(onSketchPos);
|
||||
seekAndRenderAutoConstraint(sugConstr1,
|
||||
@@ -78,7 +80,7 @@ public:
|
||||
double rx0 = onSketchPos.x - EditCurve[0].x;
|
||||
double ry0 = onSketchPos.y - EditCurve[0].y;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
double angle = i * M_PI / 16.0;
|
||||
double angle = i * pi / 16.0;
|
||||
double rx1 = rx0 * cos(angle) + ry0 * sin(angle);
|
||||
double ry1 = -rx0 * sin(angle) + ry0 * cos(angle);
|
||||
EditCurve[1 + i] = Base::Vector2d(EditCurve[0].x + rx1, EditCurve[0].y + ry1);
|
||||
@@ -115,7 +117,7 @@ public:
|
||||
/ (sin(angleatpoint) * cos(phi));
|
||||
|
||||
for (int i = 1; i < 16; i++) {
|
||||
double angle = i * M_PI / 16.0;
|
||||
double angle = i * pi / 16.0;
|
||||
double rx1 = a * cos(angle) * cos(phi) - b * sin(angle) * sin(phi);
|
||||
double ry1 = a * cos(angle) * sin(phi) + b * sin(angle) * cos(phi);
|
||||
EditCurve[1 + i] = Base::Vector2d(EditCurve[0].x + rx1, EditCurve[0].y + ry1);
|
||||
@@ -161,7 +163,7 @@ public:
|
||||
+ (onSketchPos.y - centerPoint.y) * sin(phi)))
|
||||
- startAngle;
|
||||
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI;
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * pi;
|
||||
arcAngle = abs(angle1 - arcAngle) < abs(angle2 - arcAngle) ? angle1 : angle2;
|
||||
|
||||
for (int i = 0; i < 34; i++) {
|
||||
@@ -178,7 +180,7 @@ public:
|
||||
SbString text;
|
||||
std::string aString = lengthToDisplayFormat(a, 1);
|
||||
std::string bString = lengthToDisplayFormat(b, 1);
|
||||
std::string angleString = angleToDisplayFormat(arcAngle * 180.0 / M_PI, 1);
|
||||
std::string angleString = angleToDisplayFormat(arcAngle * 180.0 / pi, 1);
|
||||
text.sprintf(" (R%s, R%s, %s)",
|
||||
aString.c_str(),
|
||||
bString.c_str(),
|
||||
@@ -222,6 +224,9 @@ public:
|
||||
bool releaseButton(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
Q_UNUSED(onSketchPos);
|
||||
|
||||
using std::numbers::pi;
|
||||
|
||||
if (Mode == STATUS_Close) {
|
||||
unsetCursor();
|
||||
resetPositionText();
|
||||
@@ -245,7 +250,7 @@ public:
|
||||
+ (endPoint.y - centerPoint.y) * sin(phi)))
|
||||
- startAngle;
|
||||
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI;
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * pi;
|
||||
arcAngle = abs(angle1 - arcAngle) < abs(angle2 - arcAngle) ? angle1 : angle2;
|
||||
|
||||
bool isOriginalArcCCW = true;
|
||||
@@ -281,8 +286,8 @@ public:
|
||||
perp.Scale(abs(b));
|
||||
majAxisPoint = centerPoint + perp;
|
||||
minAxisPoint = centerPoint + minAxisDir;
|
||||
endAngle += M_PI / 2;
|
||||
startAngle += M_PI / 2;
|
||||
endAngle += pi / 2;
|
||||
startAngle += pi / 2;
|
||||
}
|
||||
|
||||
int currentgeoid = getHighestCurveIndex();
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
if (!boost::math::isnan(b)) {
|
||||
for (int i = 15; i >= -15; i--) {
|
||||
// P(U) = O + MajRad*Cosh(U)*XDir + MinRad*Sinh(U)*YDir
|
||||
// double angle = i*M_PI/16.0;
|
||||
// double angle = i*std::numbers::pi/16.0;
|
||||
double angle = i * angleatpoint / 15;
|
||||
double rx = a * cosh(angle) * cos(phi) - b * sinh(angle) * sin(phi);
|
||||
double ry = a * cosh(angle) * sin(phi) + b * sinh(angle) * cos(phi);
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
|
||||
/*double angle1 = angleatpoint - startAngle;
|
||||
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI ;
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * std::numbers::pi ;
|
||||
arcAngle = abs(angle1-arcAngle) < abs(angle2-arcAngle) ? angle1 : angle2;*/
|
||||
|
||||
arcAngle = angleatpoint - startAngle;
|
||||
@@ -290,8 +290,8 @@ public:
|
||||
perp.Scale(abs(b));
|
||||
majAxisPoint = centerPoint + perp;
|
||||
minAxisPoint = centerPoint + minAxisDir;
|
||||
endAngle += M_PI / 2;
|
||||
startAngle += M_PI / 2;
|
||||
endAngle += std::numbers::pi / 2;
|
||||
startAngle += std::numbers::pi / 2;
|
||||
}
|
||||
|
||||
int currentgeoid = getHighestCurveIndex();
|
||||
|
||||
@@ -133,7 +133,7 @@ private:
|
||||
startAngle = startAngleBackup;
|
||||
|
||||
double angle1 = (onSketchPos - centerPoint).Angle() - startAngle;
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI;
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * std::numbers::pi;
|
||||
arcAngle = abs(angle1 - arcAngle) < abs(angle2 - arcAngle) ? angle1 : angle2;
|
||||
|
||||
reverseIfNecessary();
|
||||
@@ -305,6 +305,8 @@ private:
|
||||
|
||||
void createShape(bool onlyeditoutline) override
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
ShapeGeometry.clear();
|
||||
|
||||
if (radius < Precision::Confusion()) {
|
||||
@@ -331,14 +333,14 @@ private:
|
||||
isConstructionMode());
|
||||
|
||||
addArcToShapeGeometry(toVector3d(startPoint),
|
||||
angleReversed ? endAngle : startAngle + M_PI,
|
||||
angleReversed ? endAngle + M_PI : startAngle + 2 * M_PI,
|
||||
angleReversed ? endAngle : startAngle + pi,
|
||||
angleReversed ? endAngle + pi : startAngle + 2 * pi,
|
||||
r,
|
||||
isConstructionMode());
|
||||
|
||||
addArcToShapeGeometry(toVector3d(endPoint),
|
||||
angleReversed ? startAngle + M_PI : endAngle,
|
||||
angleReversed ? startAngle + 2 * M_PI : M_PI + endAngle,
|
||||
angleReversed ? startAngle + pi : endAngle,
|
||||
angleReversed ? startAngle + 2 * pi : pi + endAngle,
|
||||
r,
|
||||
isConstructionMode());
|
||||
|
||||
@@ -635,7 +637,7 @@ void DSHArcSlotControllerBase::doEnforceControlParameters(Base::Vector2d& onSket
|
||||
if (onViewParameters[OnViewParameter::Fifth]->isSet) {
|
||||
double arcAngle =
|
||||
Base::toRadians(onViewParameters[OnViewParameter::Fifth]->getValue());
|
||||
if (fmod(fabs(arcAngle), 2 * M_PI) < Precision::Confusion()) {
|
||||
if (fmod(fabs(arcAngle), 2 * std::numbers::pi) < Precision::Confusion()) {
|
||||
unsetOnViewParameter(onViewParameters[OnViewParameter::Fifth].get());
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -110,6 +110,9 @@ public:
|
||||
void mouseMove(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
Q_UNUSED(onSketchPos);
|
||||
|
||||
using std::numbers::pi;
|
||||
|
||||
if (Mode == STATUS_SEEK_Second) {
|
||||
const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(BaseGeoId);
|
||||
if (geom->is<Part::GeomLineSegment>()) {
|
||||
@@ -142,7 +145,7 @@ public:
|
||||
*/
|
||||
bool inCurve = (projection.Length() < recenteredLine.Length()
|
||||
&& projection.GetAngle(recenteredLine)
|
||||
< 0.1); // Two possible values here, M_PI and 0, but 0.1 is to
|
||||
< 0.1); // Two possible values here, pi and 0, but 0.1 is to
|
||||
// avoid floating point problems.
|
||||
if (inCurve) {
|
||||
Increment = SavedExtendFromStart
|
||||
@@ -185,8 +188,8 @@ public:
|
||||
bool isCCWFromStart = crossProduct(angle, startAngle) < 0;
|
||||
if (outOfArc) {
|
||||
if (isCCWFromStart) {
|
||||
modStartAngle -= 2 * M_PI - angleToStartAngle;
|
||||
modArcAngle += 2 * M_PI - angleToStartAngle;
|
||||
modStartAngle -= 2 * pi - angleToStartAngle;
|
||||
modArcAngle += 2 * pi - angleToStartAngle;
|
||||
}
|
||||
else {
|
||||
modStartAngle -= angleToStartAngle;
|
||||
@@ -199,8 +202,8 @@ public:
|
||||
modArcAngle -= angleToStartAngle;
|
||||
}
|
||||
else {
|
||||
modStartAngle += 2 * M_PI - angleToStartAngle;
|
||||
modArcAngle -= 2 * M_PI - angleToStartAngle;
|
||||
modStartAngle += 2 * pi - angleToStartAngle;
|
||||
modArcAngle -= 2 * pi - angleToStartAngle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,7 +211,7 @@ public:
|
||||
bool isCWFromEnd = crossProduct(angle, endAngle) >= 0;
|
||||
if (outOfArc) {
|
||||
if (isCWFromEnd) {
|
||||
modArcAngle += 2 * M_PI - angleToEndAngle;
|
||||
modArcAngle += 2 * pi - angleToEndAngle;
|
||||
}
|
||||
else {
|
||||
modArcAngle += angleToEndAngle;
|
||||
@@ -219,7 +222,7 @@ public:
|
||||
modArcAngle -= angleToEndAngle;
|
||||
}
|
||||
else {
|
||||
modArcAngle -= 2 * M_PI - angleToEndAngle;
|
||||
modArcAngle -= 2 * pi - angleToEndAngle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,16 +646,17 @@ void DSHLineController::addConstraints()
|
||||
};
|
||||
|
||||
auto constraintp4angle = [&]() {
|
||||
using std::numbers::pi;
|
||||
|
||||
double angle = Base::toRadians(p4);
|
||||
if (fabs(angle - M_PI) < Precision::Confusion()
|
||||
|| fabs(angle + M_PI) < Precision::Confusion()
|
||||
if (fabs(angle - pi) < Precision::Confusion() || fabs(angle + pi) < Precision::Confusion()
|
||||
|| fabs(angle) < Precision::Confusion()) {
|
||||
Gui::cmdAppObjectArgs(obj,
|
||||
"addConstraint(Sketcher.Constraint('Horizontal',%d)) ",
|
||||
firstCurve);
|
||||
}
|
||||
else if (fabs(angle - M_PI / 2) < Precision::Confusion()
|
||||
|| fabs(angle + M_PI / 2) < Precision::Confusion()) {
|
||||
else if (fabs(angle - pi / 2) < Precision::Confusion()
|
||||
|| fabs(angle + pi / 2) < Precision::Confusion()) {
|
||||
Gui::cmdAppObjectArgs(obj,
|
||||
"addConstraint(Sketcher.Constraint('Vertical',%d)) ",
|
||||
firstCurve);
|
||||
|
||||
@@ -188,6 +188,8 @@ public:
|
||||
|
||||
void mouseMove(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
suppressTransition = false;
|
||||
if (Mode == STATUS_SEEK_First) {
|
||||
setPositionText(onSketchPos);
|
||||
@@ -222,7 +224,7 @@ public:
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string lengthString = lengthToDisplayFormat(length, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / M_PI, 1);
|
||||
std::string angleString = angleToDisplayFormat(angle * 180.0 / pi, 1);
|
||||
text.sprintf(" (%s, %s)", lengthString.c_str(), angleString.c_str());
|
||||
setPositionText(EditCurve[1], text);
|
||||
}
|
||||
@@ -289,14 +291,14 @@ public:
|
||||
arcAngle = 0.f;
|
||||
}
|
||||
if (arcRadius >= 0 && arcAngle > 0) {
|
||||
arcAngle -= 2 * M_PI;
|
||||
arcAngle -= 2 * pi;
|
||||
}
|
||||
if (arcRadius < 0 && arcAngle < 0) {
|
||||
arcAngle += 2 * M_PI;
|
||||
arcAngle += 2 * pi;
|
||||
}
|
||||
|
||||
if (SnapMode == SNAP_MODE_45Degree) {
|
||||
arcAngle = round(arcAngle / (M_PI / 4)) * M_PI / 4;
|
||||
arcAngle = round(arcAngle / (pi / 4)) * pi / 4;
|
||||
}
|
||||
|
||||
endAngle = startAngle + arcAngle;
|
||||
@@ -316,7 +318,7 @@ public:
|
||||
if (showCursorCoords()) {
|
||||
SbString text;
|
||||
std::string radiusString = lengthToDisplayFormat(std::abs(arcRadius), 1);
|
||||
std::string angleString = angleToDisplayFormat(arcAngle * 180.0 / M_PI, 1);
|
||||
std::string angleString = angleToDisplayFormat(arcAngle * 180.0 / pi, 1);
|
||||
text.sprintf(" (R%s, %s)", radiusString.c_str(), angleString.c_str());
|
||||
setPositionText(onSketchPos, text);
|
||||
}
|
||||
@@ -536,8 +538,8 @@ public:
|
||||
|
||||
// #3974: if in radians, the printf %f defaults to six decimals, which leads to
|
||||
// loss of precision
|
||||
double arcAngle =
|
||||
abs(round((endAngle - startAngle) / (M_PI / 4)) * 45); // in degrees
|
||||
double arcAngle = abs(round((endAngle - startAngle) / (std::numbers::pi / 4))
|
||||
* 45); // in degrees
|
||||
|
||||
Gui::cmdAppObjectArgs(sketchgui->getObject(),
|
||||
"addConstraint(Sketcher.Constraint('Angle',%i,App.Units."
|
||||
|
||||
@@ -932,7 +932,7 @@ private:
|
||||
|
||||
void findOffsetLength()
|
||||
{
|
||||
double newOffsetLength = DBL_MAX;
|
||||
double newOffsetLength = std::numeric_limits<double>::max();
|
||||
|
||||
BRepBuilderAPI_MakeVertex mkVertex({endpoint.x, endpoint.y, 0.0});
|
||||
TopoDS_Vertex vertex = mkVertex.Vertex();
|
||||
@@ -960,7 +960,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
if (newOffsetLength != DBL_MAX) {
|
||||
if (newOffsetLength != std::numeric_limits<double>::max()) {
|
||||
offsetLength = newOffsetLength;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +242,8 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
double angleOfSeparation = 2.0 * M_PI / static_cast<double>(numberOfCorners); // NOLINT
|
||||
double angleOfSeparation =
|
||||
2.0 * std::numbers::pi / static_cast<double>(numberOfCorners); // NOLINT
|
||||
double cos_v = cos(angleOfSeparation);
|
||||
double sin_v = sin(angleOfSeparation);
|
||||
|
||||
|
||||
@@ -111,6 +111,8 @@ public:
|
||||
private:
|
||||
void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
switch (state()) {
|
||||
case SelectMode::SeekFirst: {
|
||||
toolWidgetManager.drawPositionAtCursor(onSketchPos);
|
||||
@@ -144,8 +146,8 @@ private:
|
||||
corner2 = Base::Vector2d(corner1.x, onSketchPos.y);
|
||||
cornersReversed = true;
|
||||
}
|
||||
angle123 = M_PI / 2;
|
||||
angle412 = M_PI / 2;
|
||||
angle123 = pi / 2;
|
||||
angle412 = pi / 2;
|
||||
}
|
||||
else if (constructionMethod() == ConstructionMethod::CenterAndCorner) {
|
||||
toolWidgetManager.drawDirectionAtCursor(onSketchPos, center);
|
||||
@@ -162,8 +164,8 @@ private:
|
||||
corner2 = Base::Vector2d(corner1.x, onSketchPos.y);
|
||||
cornersReversed = true;
|
||||
}
|
||||
angle123 = M_PI / 2;
|
||||
angle412 = M_PI / 2;
|
||||
angle123 = pi / 2;
|
||||
angle412 = pi / 2;
|
||||
}
|
||||
else if (constructionMethod() == ConstructionMethod::ThreePoints) {
|
||||
toolWidgetManager.drawDirectionAtCursor(onSketchPos, corner1);
|
||||
@@ -174,8 +176,8 @@ private:
|
||||
perpendicular.y = (corner2 - corner1).x;
|
||||
corner3 = corner2 + perpendicular;
|
||||
corner4 = corner1 + perpendicular;
|
||||
angle123 = M_PI / 2;
|
||||
angle412 = M_PI / 2;
|
||||
angle123 = pi / 2;
|
||||
angle412 = pi / 2;
|
||||
corner2Initial = corner2;
|
||||
side = getPointSideOfVector(corner3, corner2 - corner1, corner1);
|
||||
}
|
||||
@@ -189,8 +191,8 @@ private:
|
||||
perpendicular.y = (onSketchPos - center).x;
|
||||
corner2 = center + perpendicular;
|
||||
corner4 = center - perpendicular;
|
||||
angle123 = M_PI / 2;
|
||||
angle412 = M_PI / 2;
|
||||
angle123 = pi / 2;
|
||||
angle412 = pi / 2;
|
||||
side = getPointSideOfVector(corner2, corner3 - corner1, corner1);
|
||||
}
|
||||
|
||||
@@ -247,7 +249,7 @@ private:
|
||||
acos((a.x * b.x + a.y * b.y)
|
||||
/ (sqrt(a.x * a.x + a.y * a.y) * sqrt(b.x * b.x + b.y * b.y)));
|
||||
}
|
||||
angle412 = M_PI - angle123;
|
||||
angle412 = pi - angle123;
|
||||
if (roundCorners) {
|
||||
radius = std::min(length, width) / 6 // NOLINT
|
||||
* std::min(sqrt(1 - cos(angle412) * cos(angle412)),
|
||||
@@ -276,7 +278,7 @@ private:
|
||||
acos((a.x * b.x + a.y * b.y)
|
||||
/ (sqrt(a.x * a.x + a.y * a.y) * sqrt(b.x * b.x + b.y * b.y)));
|
||||
}
|
||||
angle123 = M_PI - angle412;
|
||||
angle123 = pi - angle412;
|
||||
if (roundCorners) {
|
||||
radius = std::min(length, width) / 6 // NOLINT
|
||||
* std::min(sqrt(1 - cos(angle412) * cos(angle412)),
|
||||
@@ -677,7 +679,7 @@ private:
|
||||
width = vecW.Length();
|
||||
angle = vecL.Angle();
|
||||
if (length < Precision::Confusion() || width < Precision::Confusion()
|
||||
|| fmod(fabs(angle123), M_PI) < Precision::Confusion()) {
|
||||
|| fmod(fabs(angle123), std::numbers::pi) < Precision::Confusion()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -738,9 +740,11 @@ private:
|
||||
|
||||
void createFirstRectangleFillets(Base::Vector2d vecL, Base::Vector2d vecW, double L1, double L2)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
// center points required later for special case of round corner frame with
|
||||
// radiusFrame = 0.
|
||||
double end = angle - M_PI / 2;
|
||||
double end = angle - pi / 2;
|
||||
|
||||
Base::Vector2d b1 = (vecL + vecW) / (vecL + vecW).Length();
|
||||
Base::Vector2d b2 = (vecL - vecW) / (vecL - vecW).Length();
|
||||
@@ -749,16 +753,18 @@ private:
|
||||
center3 = toVector3d(corner3 - b1 * L2);
|
||||
center4 = toVector3d(corner4 + b2 * L1);
|
||||
|
||||
addArcToShapeGeometry(center1, end - M_PI + angle412, end, radius, isConstructionMode());
|
||||
addArcToShapeGeometry(center2, end, end - M_PI - angle123, radius, isConstructionMode());
|
||||
addArcToShapeGeometry(center3, end + angle412, end - M_PI, radius, isConstructionMode());
|
||||
addArcToShapeGeometry(center4, end - M_PI, end - angle123, radius, isConstructionMode());
|
||||
addArcToShapeGeometry(center1, end - pi + angle412, end, radius, isConstructionMode());
|
||||
addArcToShapeGeometry(center2, end, end - pi - angle123, radius, isConstructionMode());
|
||||
addArcToShapeGeometry(center3, end + angle412, end - pi, radius, isConstructionMode());
|
||||
addArcToShapeGeometry(center4, end - pi, end - angle123, radius, isConstructionMode());
|
||||
}
|
||||
|
||||
void
|
||||
createSecondRectangleGeometries(Base::Vector2d vecL, Base::Vector2d vecW, double L1, double L2)
|
||||
{
|
||||
double end = angle - M_PI / 2;
|
||||
using std::numbers::pi;
|
||||
|
||||
double end = angle - pi / 2;
|
||||
|
||||
if (radius < Precision::Confusion()) {
|
||||
radiusFrame = 0.;
|
||||
@@ -800,22 +806,22 @@ private:
|
||||
Base::Vector2d b2 = (vecL - vecW) / (vecL - vecW).Length();
|
||||
|
||||
addArcToShapeGeometry(toVector3d(frameCorner1 + b1 * L2F),
|
||||
end - M_PI + angle412,
|
||||
end - pi + angle412,
|
||||
end,
|
||||
radiusFrame,
|
||||
isConstructionMode());
|
||||
addArcToShapeGeometry(toVector3d(frameCorner2 - b2 * L1F),
|
||||
end,
|
||||
end - M_PI - angle123,
|
||||
end - pi - angle123,
|
||||
radiusFrame,
|
||||
isConstructionMode());
|
||||
addArcToShapeGeometry(toVector3d(frameCorner3 - b1 * L2F),
|
||||
end + angle412,
|
||||
end - M_PI,
|
||||
end - pi,
|
||||
radiusFrame,
|
||||
isConstructionMode());
|
||||
addArcToShapeGeometry(toVector3d(frameCorner4 + b2 * L1F),
|
||||
end - M_PI,
|
||||
end - pi,
|
||||
end - angle123,
|
||||
radiusFrame,
|
||||
isConstructionMode());
|
||||
@@ -1313,7 +1319,7 @@ private:
|
||||
firstCurve + 1,
|
||||
Sketcher::PointPos::none,
|
||||
firstCurve + 3);
|
||||
if (fabs(angle123 - M_PI / 2) < Precision::Confusion()) {
|
||||
if (fabs(angle123 - std::numbers::pi / 2) < Precision::Confusion()) {
|
||||
addToShapeConstraints(Sketcher::Perpendicular,
|
||||
firstCurve,
|
||||
Sketcher::PointPos::none,
|
||||
@@ -1932,7 +1938,7 @@ void DSHRectangleControllerBase::doEnforceControlParameters(Base::Vector2d& onSk
|
||||
if (onViewParameters[OnViewParameter::Sixth]->isSet) {
|
||||
double angle =
|
||||
Base::toRadians(onViewParameters[OnViewParameter::Sixth]->getValue());
|
||||
if (fmod(angle, M_PI) < Precision::Confusion()) {
|
||||
if (fmod(angle, std::numbers::pi) < Precision::Confusion()) {
|
||||
unsetOnViewParameter(onViewParameters[OnViewParameter::Sixth].get());
|
||||
return;
|
||||
}
|
||||
@@ -1944,8 +1950,8 @@ void DSHRectangleControllerBase::doEnforceControlParameters(Base::Vector2d& onSk
|
||||
|
||||
int sign = handler->side != sign1 ? 1 : -1;
|
||||
|
||||
double angle123 =
|
||||
(handler->corner2Initial - handler->corner1).Angle() + M_PI + sign * angle;
|
||||
double angle123 = (handler->corner2Initial - handler->corner1).Angle()
|
||||
+ std::numbers::pi + sign * angle;
|
||||
|
||||
onSketchPos.x = handler->corner2Initial.x + cos(angle123) * width;
|
||||
onSketchPos.y = handler->corner2Initial.y + sin(angle123) * width;
|
||||
@@ -1969,12 +1975,12 @@ void DSHRectangleControllerBase::doEnforceControlParameters(Base::Vector2d& onSk
|
||||
if (onViewParameters[OnViewParameter::Sixth]->isSet) {
|
||||
double c =
|
||||
Base::toRadians(onViewParameters[OnViewParameter::Sixth]->getValue());
|
||||
if (fmod(c, M_PI) < Precision::Confusion()) {
|
||||
if (fmod(c, std::numbers::pi) < Precision::Confusion()) {
|
||||
unsetOnViewParameter(onViewParameters[OnViewParameter::Sixth].get());
|
||||
return;
|
||||
}
|
||||
|
||||
double a = asin(width * sin(M_PI - c)
|
||||
double a = asin(width * sin(std::numbers::pi - c)
|
||||
/ (handler->corner3 - handler->corner1).Length());
|
||||
|
||||
int sign1 = handler->getPointSideOfVector(onSketchPos,
|
||||
@@ -2399,6 +2405,8 @@ void DSHRectangleController::doChangeDrawSketchHandlerMode()
|
||||
template<>
|
||||
void DSHRectangleController::addConstraints()
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
App::DocumentObject* obj = handler->sketchgui->getObject();
|
||||
|
||||
int firstCurve = handler->firstCurve;
|
||||
@@ -2569,15 +2577,15 @@ void DSHRectangleController::addConstraints()
|
||||
|
||||
if (handler->constructionMethod() == ConstructionMethod::ThreePoints) {
|
||||
if (angleSet) {
|
||||
if (fabs(angle - M_PI) < Precision::Confusion()
|
||||
|| fabs(angle + M_PI) < Precision::Confusion()
|
||||
if (fabs(angle - pi) < Precision::Confusion()
|
||||
|| fabs(angle + pi) < Precision::Confusion()
|
||||
|| fabs(angle) < Precision::Confusion()) {
|
||||
Gui::cmdAppObjectArgs(obj,
|
||||
"addConstraint(Sketcher.Constraint('Horizontal',%d)) ",
|
||||
firstCurve);
|
||||
}
|
||||
else if (fabs(angle - M_PI / 2) < Precision::Confusion()
|
||||
|| fabs(angle + M_PI / 2) < Precision::Confusion()) {
|
||||
else if (fabs(angle - pi / 2) < Precision::Confusion()
|
||||
|| fabs(angle + pi / 2) < Precision::Confusion()) {
|
||||
Gui::cmdAppObjectArgs(obj,
|
||||
"addConstraint(Sketcher.Constraint('Vertical',%d)) ",
|
||||
firstCurve);
|
||||
@@ -2591,7 +2599,7 @@ void DSHRectangleController::addConstraints()
|
||||
}
|
||||
}
|
||||
if (innerAngleSet) {
|
||||
if (fabs(innerAngle - M_PI / 2) > Precision::Confusion()) {
|
||||
if (fabs(innerAngle - pi / 2) > Precision::Confusion()) {
|
||||
// if 90? then perpendicular already created.
|
||||
Gui::cmdAppObjectArgs(obj,
|
||||
"addConstraint(Sketcher.Constraint('Angle',%d,%d,%d,%d,%f)) ",
|
||||
@@ -2617,7 +2625,7 @@ void DSHRectangleController::addConstraints()
|
||||
obj);
|
||||
}
|
||||
if (innerAngleSet) {
|
||||
if (fabs(innerAngle - M_PI / 2) > Precision::Confusion()) {
|
||||
if (fabs(innerAngle - pi / 2) > Precision::Confusion()) {
|
||||
// if 90? then perpendicular already created.
|
||||
Gui::cmdAppObjectArgs(obj,
|
||||
"addConstraint(Sketcher.Constraint('Angle',%d,%d,%d,%d,%f)) ",
|
||||
|
||||
@@ -103,7 +103,7 @@ private:
|
||||
endpoint = centerPoint + length * Base::Vector2d(cos(endAngle), sin(endAngle));
|
||||
|
||||
double angle1 = endAngle - startAngle;
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI;
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * std::numbers::pi;
|
||||
totalAngle = abs(angle1 - totalAngle) < abs(angle2 - totalAngle) ? angle1 : angle2;
|
||||
|
||||
CreateAndDrawShapeGeometry();
|
||||
@@ -408,10 +408,11 @@ private:
|
||||
// the new geometry.
|
||||
/*if (cstr->Type == DistanceX || cstr->Type == DistanceY) {
|
||||
//DistanceX/Y can be applied only if the rotation if 90 or 180.
|
||||
if (fabs(fmod(individualAngle, M_PI)) < Precision::Confusion()) {
|
||||
if (fabs(fmod(individualAngle, std::numbers::pi)) <
|
||||
Precision::Confusion()) {
|
||||
// ok and nothing to do actually
|
||||
}
|
||||
else if (fabs(fmod(individualAngle, M_PI * 0.5)) <
|
||||
else if (fabs(fmod(individualAngle, std::numbers::pi * 0.5)) <
|
||||
Precision::Confusion()) { cstr->Type = cstr->Type == DistanceX ?
|
||||
DistanceY : DistanceX;
|
||||
}
|
||||
@@ -567,7 +568,7 @@ void DSHRotateControllerBase::doEnforceControlParameters(Base::Vector2d& onSketc
|
||||
|
||||
double arcAngle =
|
||||
Base::toRadians(onViewParameters[OnViewParameter::Third]->getValue());
|
||||
if (fmod(fabs(arcAngle), 2 * M_PI) < Precision::Confusion()) {
|
||||
if (fmod(fabs(arcAngle), 2 * std::numbers::pi) < Precision::Confusion()) {
|
||||
unsetOnViewParameter(onViewParameters[OnViewParameter::Third].get());
|
||||
return;
|
||||
}
|
||||
@@ -580,7 +581,7 @@ void DSHRotateControllerBase::doEnforceControlParameters(Base::Vector2d& onSketc
|
||||
|
||||
double arcAngle =
|
||||
Base::toRadians(onViewParameters[OnViewParameter::Fourth]->getValue());
|
||||
if (fmod(fabs(arcAngle), 2 * M_PI) < Precision::Confusion()) {
|
||||
if (fmod(fabs(arcAngle), 2 * std::numbers::pi) < Precision::Confusion()) {
|
||||
unsetOnViewParameter(onViewParameters[OnViewParameter::Fourth].get());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -241,6 +241,8 @@ private:
|
||||
|
||||
void createShape(bool onlyeditoutline) override
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
ShapeGeometry.clear();
|
||||
|
||||
if (length < Precision::Confusion() || radius < Precision::Confusion()) {
|
||||
@@ -248,14 +250,14 @@ private:
|
||||
}
|
||||
|
||||
Part::GeomArcOfCircle* arc1 = addArcToShapeGeometry(toVector3d(startPoint),
|
||||
M_PI / 2 + angle,
|
||||
1.5 * M_PI + angle,
|
||||
pi / 2 + angle,
|
||||
1.5 * pi + angle,
|
||||
radius,
|
||||
isConstructionMode());
|
||||
|
||||
Part::GeomArcOfCircle* arc2 = addArcToShapeGeometry(toVector3d(secondPoint),
|
||||
1.5 * M_PI + angle,
|
||||
M_PI / 2 + angle,
|
||||
1.5 * pi + angle,
|
||||
pi / 2 + angle,
|
||||
radius,
|
||||
isConstructionMode());
|
||||
|
||||
@@ -323,13 +325,15 @@ private:
|
||||
|
||||
void checkHorizontalVertical()
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
isHorizontal = false;
|
||||
isVertical = false;
|
||||
|
||||
if (fmod(fabs(angle), M_PI) < Precision::Confusion()) {
|
||||
if (fmod(fabs(angle), pi) < Precision::Confusion()) {
|
||||
isHorizontal = true;
|
||||
}
|
||||
else if (fmod(fabs(angle + M_PI / 2), M_PI) < Precision::Confusion()) {
|
||||
else if (fmod(fabs(angle + pi / 2), pi) < Precision::Confusion()) {
|
||||
isVertical = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,7 +584,8 @@ void DSHTranslateControllerBase::doEnforceControlParameters(Base::Vector2d& onSk
|
||||
}
|
||||
|
||||
if (onViewParameters[OnViewParameter::Fourth]->isSet) {
|
||||
double angle = onViewParameters[OnViewParameter::Fourth]->getValue() * M_PI / 180;
|
||||
double angle =
|
||||
onViewParameters[OnViewParameter::Fourth]->getValue() * std::numbers::pi / 180;
|
||||
onSketchPos.x = handler->referencePoint.x + cos(angle) * length;
|
||||
onSketchPos.y = handler->referencePoint.y + sin(angle) * length;
|
||||
}
|
||||
@@ -607,7 +608,8 @@ void DSHTranslateControllerBase::doEnforceControlParameters(Base::Vector2d& onSk
|
||||
}
|
||||
|
||||
if (onViewParameters[OnViewParameter::Sixth]->isSet) {
|
||||
double angle = onViewParameters[OnViewParameter::Sixth]->getValue() * M_PI / 180;
|
||||
double angle =
|
||||
onViewParameters[OnViewParameter::Sixth]->getValue() * std::numbers::pi / 180;
|
||||
onSketchPos.x = handler->referencePoint.x + cos(angle) * length;
|
||||
onSketchPos.y = handler->referencePoint.y + sin(angle) * length;
|
||||
}
|
||||
@@ -647,7 +649,7 @@ void DSHTranslateController::adaptParameters(Base::Vector2d onSketchPos)
|
||||
Base::Vector2d vec2d = Base::Vector2d(handler->firstTranslationVector.x,
|
||||
handler->firstTranslationVector.y);
|
||||
double angle = vec2d.Angle();
|
||||
double range = angle * 180 / M_PI;
|
||||
double range = angle * 180 / std::numbers::pi;
|
||||
|
||||
if (!onViewParameters[OnViewParameter::Fourth]->isSet) {
|
||||
setOnViewParameterValue(OnViewParameter::Fourth, range, Base::Unit::Angle);
|
||||
@@ -669,7 +671,7 @@ void DSHTranslateController::adaptParameters(Base::Vector2d onSketchPos)
|
||||
Base::Vector2d vec2d = Base::Vector2d(handler->secondTranslationVector.x,
|
||||
handler->secondTranslationVector.y);
|
||||
double angle = vec2d.Angle();
|
||||
double range = angle * 180 / M_PI;
|
||||
double range = angle * 180 / std::numbers::pi;
|
||||
|
||||
if (!onViewParameters[OnViewParameter::Sixth]->isSet) {
|
||||
setOnViewParameterValue(OnViewParameter::Sixth, range, Base::Unit::Angle);
|
||||
|
||||
@@ -114,6 +114,8 @@ void EditModeConstraintCoinManager::updateVirtualSpace()
|
||||
|
||||
void EditModeConstraintCoinManager::processConstraints(const GeoListFacade& geolistfacade)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
const auto& constrlist = ViewProviderSketchCoinAttorney::getConstraints(viewProvider);
|
||||
|
||||
auto zConstrH = ViewProviderSketchCoinAttorney::getViewOrientationFactor(viewProvider)
|
||||
@@ -262,7 +264,7 @@ Restart:
|
||||
const Part::GeomCircle* circle =
|
||||
static_cast<const Part::GeomCircle*>(geo);
|
||||
ra = circle->getRadius();
|
||||
angle = M_PI / 4;
|
||||
angle = pi / 4;
|
||||
midpos = circle->getCenter();
|
||||
}
|
||||
else if (geo->is<Part::GeomArcOfCircle>()) {
|
||||
@@ -281,7 +283,7 @@ Restart:
|
||||
rb = ellipse->getMinorRadius();
|
||||
Base::Vector3d majdir = ellipse->getMajorAxisDir();
|
||||
angle = atan2(majdir.y, majdir.x);
|
||||
angleplus = M_PI / 4;
|
||||
angleplus = pi / 4;
|
||||
midpos = ellipse->getCenter();
|
||||
}
|
||||
else if (geo->is<Part::GeomArcOfEllipse>()) {
|
||||
@@ -460,7 +462,7 @@ Restart:
|
||||
|
||||
norm1.Normalize();
|
||||
dir1 = norm1;
|
||||
dir1.RotateZ(-M_PI / 2.0);
|
||||
dir1.RotateZ(-pi / 2.0);
|
||||
}
|
||||
else if (Constr->FirstPos == Sketcher::PointPos::none) {
|
||||
|
||||
@@ -485,7 +487,7 @@ Restart:
|
||||
else if (geo1->is<Part::GeomCircle>()) {
|
||||
const Part::GeomCircle* circle =
|
||||
static_cast<const Part::GeomCircle*>(geo1);
|
||||
norm1 = Base::Vector3d(cos(M_PI / 4), sin(M_PI / 4), 0);
|
||||
norm1 = Base::Vector3d(cos(pi / 4), sin(pi / 4), 0);
|
||||
dir1 = Base::Vector3d(-norm1.y, norm1.x, 0);
|
||||
midpos1 = circle->getCenter() + circle->getRadius() * norm1;
|
||||
}
|
||||
@@ -514,7 +516,7 @@ Restart:
|
||||
else if (geo2->is<Part::GeomCircle>()) {
|
||||
const Part::GeomCircle* circle =
|
||||
static_cast<const Part::GeomCircle*>(geo2);
|
||||
norm2 = Base::Vector3d(cos(M_PI / 4), sin(M_PI / 4), 0);
|
||||
norm2 = Base::Vector3d(cos(pi / 4), sin(pi / 4), 0);
|
||||
dir2 = Base::Vector3d(-norm2.y, norm2.x, 0);
|
||||
midpos2 = circle->getCenter() + circle->getRadius() * norm2;
|
||||
}
|
||||
@@ -576,7 +578,7 @@ Restart:
|
||||
const Part::GeomCircle* circle =
|
||||
static_cast<const Part::GeomCircle*>(geo1);
|
||||
r1a = circle->getRadius();
|
||||
angle1 = M_PI / 4;
|
||||
angle1 = pi / 4;
|
||||
midpos1 = circle->getCenter();
|
||||
}
|
||||
else if (geo1->is<Part::GeomArcOfCircle>()) {
|
||||
@@ -595,7 +597,7 @@ Restart:
|
||||
r1b = ellipse->getMinorRadius();
|
||||
Base::Vector3d majdir = ellipse->getMajorAxisDir();
|
||||
angle1 = atan2(majdir.y, majdir.x);
|
||||
angle1plus = M_PI / 4;
|
||||
angle1plus = pi / 4;
|
||||
midpos1 = ellipse->getCenter();
|
||||
}
|
||||
else if (geo1->is<Part::GeomArcOfEllipse>()) {
|
||||
@@ -641,7 +643,7 @@ Restart:
|
||||
const Part::GeomCircle* circle =
|
||||
static_cast<const Part::GeomCircle*>(geo2);
|
||||
r2a = circle->getRadius();
|
||||
angle2 = M_PI / 4;
|
||||
angle2 = pi / 4;
|
||||
midpos2 = circle->getCenter();
|
||||
}
|
||||
else if (geo2->is<Part::GeomArcOfCircle>()) {
|
||||
@@ -660,7 +662,7 @@ Restart:
|
||||
r2b = ellipse->getMinorRadius();
|
||||
Base::Vector3d majdir = ellipse->getMajorAxisDir();
|
||||
angle2 = atan2(majdir.y, majdir.x);
|
||||
angle2plus = M_PI / 4;
|
||||
angle2plus = pi / 4;
|
||||
midpos2 = ellipse->getCenter();
|
||||
}
|
||||
else if (geo2->is<Part::GeomArcOfEllipse>()) {
|
||||
@@ -968,7 +970,7 @@ Restart:
|
||||
// otherwise We still use findHelperAngles before to find if helper
|
||||
// is needed.
|
||||
helperStartAngle1 = endAngle;
|
||||
helperRange1 = 2 * M_PI - (endAngle - startAngle);
|
||||
helperRange1 = 2 * pi - (endAngle - startAngle);
|
||||
|
||||
numPoints++;
|
||||
}
|
||||
@@ -991,7 +993,7 @@ Restart:
|
||||
|
||||
if (helperRange2 != 0.) {
|
||||
helperStartAngle2 = endAngle;
|
||||
helperRange2 = 2 * M_PI - (endAngle - startAngle);
|
||||
helperRange2 = 2 * pi - (endAngle - startAngle);
|
||||
|
||||
numPoints++;
|
||||
}
|
||||
@@ -1089,7 +1091,7 @@ Restart:
|
||||
// getSolvedSketch().calculateNormalAtPoint(Constr->Second, pos.x, pos.y);
|
||||
norm.Normalize();
|
||||
Base::Vector3d dir = norm;
|
||||
dir.RotateZ(-M_PI / 2.0);
|
||||
dir.RotateZ(-pi / 2.0);
|
||||
|
||||
relPos = seekConstraintPosition(
|
||||
pos,
|
||||
@@ -1340,7 +1342,7 @@ Restart:
|
||||
p1[1] = line1->getEndPoint();
|
||||
p2[0] = line2->getStartPoint();
|
||||
p2[1] = line2->getEndPoint();
|
||||
double length = DBL_MAX;
|
||||
double length = std::numeric_limits<double>::max();
|
||||
for (int i = 0; i <= 1; i++) {
|
||||
for (int j = 0; j <= 1; j++) {
|
||||
double tmp = (p2[j] - p1[i]).Length();
|
||||
@@ -1385,12 +1387,12 @@ Restart:
|
||||
// TODO: Check
|
||||
// dir1 = getSolvedSketch().calculateNormalAtPoint(Constr->First,
|
||||
// p.x, p.y);
|
||||
dir1.RotateZ(-M_PI / 2); // convert to vector of tangency by rotating
|
||||
dir1.RotateZ(-pi / 2); // convert to vector of tangency by rotating
|
||||
dir2 = getNormal(geolistfacade, Constr->Second, p);
|
||||
// TODO: Check
|
||||
// dir2 = getSolvedSketch().calculateNormalAtPoint(Constr->Second,
|
||||
// p.x, p.y);
|
||||
dir2.RotateZ(-M_PI / 2);
|
||||
dir2.RotateZ(-pi / 2);
|
||||
|
||||
startangle = atan2(dir1.y, dir1.x);
|
||||
range = atan2(dir1.x * dir2.y - dir1.y * dir2.x,
|
||||
@@ -1632,26 +1634,28 @@ void EditModeConstraintCoinManager::findHelperAngles(double& helperStartAngle,
|
||||
double startAngle,
|
||||
double endAngle)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
double margin = 0.2; // about 10deg
|
||||
if (angle < 0) {
|
||||
angle = angle + 2 * M_PI;
|
||||
angle = angle + 2 * pi;
|
||||
}
|
||||
// endAngle can be more than 2*pi as its startAngle + arcAngle
|
||||
if (endAngle > 2 * M_PI && angle < endAngle - 2 * M_PI) {
|
||||
angle = angle + 2 * M_PI;
|
||||
if (endAngle > 2 * pi && angle < endAngle - 2 * pi) {
|
||||
angle = angle + 2 * pi;
|
||||
}
|
||||
if (!(angle > startAngle && angle < endAngle)) {
|
||||
if ((angle < startAngle && startAngle - angle < angle + 2 * M_PI - endAngle)
|
||||
|| (angle > endAngle && startAngle + 2 * M_PI - angle < angle - endAngle)) {
|
||||
if ((angle < startAngle && startAngle - angle < angle + 2 * pi - endAngle)
|
||||
|| (angle > endAngle && startAngle + 2 * pi - angle < angle - endAngle)) {
|
||||
if (angle > startAngle) {
|
||||
angle -= 2 * M_PI;
|
||||
angle -= 2 * pi;
|
||||
}
|
||||
helperStartAngle = angle - margin;
|
||||
helperRange = startAngle - angle + margin;
|
||||
}
|
||||
else {
|
||||
if (angle < endAngle) {
|
||||
angle += 2 * M_PI;
|
||||
angle += 2 * pi;
|
||||
}
|
||||
helperStartAngle = endAngle;
|
||||
helperRange = angle - endAngle + margin;
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#ifdef _PreComp_
|
||||
|
||||
// standard
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
@@ -122,7 +122,8 @@ void SnapManager::ParameterObserver::updateSnapAngleParameter(const std::string&
|
||||
{
|
||||
ParameterGrp::handle hGrp = getParameterGrpHandle();
|
||||
|
||||
client.snapAngle = fmod(hGrp->GetFloat(parametername.c_str(), 5.) * M_PI / 180, 2 * M_PI);
|
||||
client.snapAngle = fmod(hGrp->GetFloat(parametername.c_str(), 5.) * std::numbers::pi / 180,
|
||||
2 * std::numbers::pi);
|
||||
}
|
||||
|
||||
void SnapManager::ParameterObserver::subscribeToParameters()
|
||||
@@ -222,7 +223,7 @@ bool SnapManager::snapAtAngle(double& x, double& y)
|
||||
double length = (pointToOverride - referencePoint).Length();
|
||||
|
||||
double angle1 = (pointToOverride - referencePoint).Angle();
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI;
|
||||
double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * std::numbers::pi;
|
||||
lastMouseAngle = abs(angle1 - lastMouseAngle) < abs(angle2 - lastMouseAngle) ? angle1 : angle2;
|
||||
|
||||
double angle = round(lastMouseAngle / snapAngle) * snapAngle;
|
||||
@@ -368,10 +369,10 @@ bool SnapManager::snapToArcMiddle(Base::Vector3d& pointToOverride, const Part::G
|
||||
double u, v;
|
||||
arc->getRange(u, v, true);
|
||||
if (v < u) {
|
||||
v += 2 * M_PI;
|
||||
v += 2 * std::numbers::pi;
|
||||
}
|
||||
double angle = v - u;
|
||||
int revert = angle < M_PI ? 1 : -1;
|
||||
int revert = angle < std::numbers::pi ? 1 : -1;
|
||||
|
||||
/*To know if we are close to the middle of the arc, we are going to compare the angle of the
|
||||
* (mouse cursor - center) to the angle of the middle of the arc. If it's less than 10% of the
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
|
||||
#include <Inventor/actions/SoGLRenderAction.h>
|
||||
|
||||
@@ -720,8 +720,9 @@ ConstraintFilterList::ConstraintFilterList(QWidget* parent)
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher/General");
|
||||
int filterState = hGrp->GetInt("ConstraintFilterState",
|
||||
INT_MAX);// INT_MAX = 1111111111111111111111111111111 in binary.
|
||||
int filterState = hGrp->GetInt(
|
||||
"ConstraintFilterState",
|
||||
std::numeric_limits<int>::max()); // INT_MAX = 01111111111111111111111111111111 in binary.
|
||||
|
||||
normalFilterCount = filterItems.size() - 2;// All filter but selected and associated
|
||||
selectedFilterIndex = normalFilterCount;
|
||||
|
||||
@@ -1124,8 +1124,9 @@ ElementFilterList::ElementFilterList(QWidget* parent)
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher/General");
|
||||
int filterState = hGrp->GetInt("ElementFilterState",
|
||||
INT_MAX);// INT_MAX = 1111111111111111111111111111111 in binary.
|
||||
int filterState = hGrp->GetInt(
|
||||
"ElementFilterState",
|
||||
std::numeric_limits<int>::max());// INT_MAX = 01111111111111111111111111111111 in binary.
|
||||
|
||||
for (auto const& filterItem : filterItems) {
|
||||
Q_UNUSED(filterItem);
|
||||
@@ -1320,7 +1321,7 @@ void TaskSketcherElements::onListMultiFilterItemChanged(QListWidgetItem* item)
|
||||
}
|
||||
|
||||
// Save the state of the filter.
|
||||
int filterState = INT_MIN;// INT_MIN = 000000000000000000000000000000 in binary.
|
||||
int filterState = 0; // All bits are cleared.
|
||||
for (int i = filterList->count() - 1; i >= 0; i--) {
|
||||
bool isChecked = filterList->item(i)->checkState() == Qt::Checked;
|
||||
filterState = filterState << 1;// we shift left first, else the list is shifted at the end.
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TaskSketcherGeneral</class>
|
||||
<widget class="QWidget" name="TaskSketcherGeneral">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>253</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>.AppleSystemUIFont</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::UrlLabel" name="labelConstrainStatusLink">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::StatefulLabel" name="labelConstrainStatus">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DOF</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="autoRecompute">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto Recompute</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::StatefulLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::UrlLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <cfloat>
|
||||
|
||||
#include <QCursor>
|
||||
#include <QLocale>
|
||||
@@ -432,7 +431,7 @@ double SketcherGui::GetPointAngle(const Base::Vector2d& p1, const Base::Vector2d
|
||||
{
|
||||
double dX = p2.x - p1.x;
|
||||
double dY = p2.y - p1.y;
|
||||
return dY >= 0 ? atan2(dY, dX) : atan2(dY, dX) + 2 * M_PI;
|
||||
return dY >= 0 ? atan2(dY, dX) : atan2(dY, dX) + 2 * std::numbers::pi;
|
||||
}
|
||||
|
||||
// Set the two points on circles at minimal distance
|
||||
|
||||
@@ -861,7 +861,7 @@ void ViewProviderSketch::getCoordsOnSketchPlane(const SbVec3f& point, const SbVe
|
||||
|
||||
// line
|
||||
Base::Vector3d R1(point[0], point[1], point[2]), RA(normal[0], normal[1], normal[2]);
|
||||
if (fabs(RN * RA) < FLT_EPSILON)
|
||||
if (fabs(RN * RA) < std::numeric_limits<float>::epsilon())
|
||||
throw Base::ZeroDivisionError("View direction is parallel to sketch plane");
|
||||
// intersection point on plane
|
||||
Base::Vector3d S = R1 + ((RN * (R0 - R1)) / (RN * RA)) * RA;
|
||||
@@ -1930,9 +1930,9 @@ void ViewProviderSketch::moveConstraint(Sketcher::Constraint* Constr, int constN
|
||||
|| Constr->Type == Weight)
|
||||
dir = (p2 - p1).Normalize();
|
||||
else if (Constr->Type == DistanceX)
|
||||
dir = Base::Vector3d((p2.x - p1.x >= FLT_EPSILON) ? 1 : -1, 0, 0);
|
||||
dir = Base::Vector3d((p2.x - p1.x >= std::numeric_limits<float>::epsilon()) ? 1 : -1, 0, 0);
|
||||
else if (Constr->Type == DistanceY)
|
||||
dir = Base::Vector3d(0, (p2.y - p1.y >= FLT_EPSILON) ? 1 : -1, 0);
|
||||
dir = Base::Vector3d(0, (p2.y - p1.y >= std::numeric_limits<float>::epsilon()) ? 1 : -1, 0);
|
||||
|
||||
if (Constr->Type == Radius || Constr->Type == Diameter || Constr->Type == Weight) {
|
||||
Constr->LabelDistance = vec.x * dir.x + vec.y * dir.y;
|
||||
@@ -2029,9 +2029,9 @@ void ViewProviderSketch::moveAngleConstraint(Sketcher::Constraint* constr, int c
|
||||
Base::Vector3d p = getSolvedSketch().getPoint(constr->Third, constr->ThirdPos);
|
||||
p0 = Base::Vector3d(p.x, p.y, 0);
|
||||
Base::Vector3d dir1 = getSolvedSketch().calculateNormalAtPoint(constr->First, p.x, p.y);
|
||||
dir1.RotateZ(-M_PI / 2);// convert to vector of tangency by rotating
|
||||
dir1.RotateZ(-std::numbers::pi / 2);// convert to vector of tangency by rotating
|
||||
Base::Vector3d dir2 = getSolvedSketch().calculateNormalAtPoint(constr->Second, p.x, p.y);
|
||||
dir2.RotateZ(-M_PI / 2);
|
||||
dir2.RotateZ(-std::numbers::pi / 2);
|
||||
|
||||
Base::Vector3d vec = Base::Vector3d(toPos.x, toPos.y, 0) - p0;
|
||||
factor = factor * Base::sgn<double>((dir1 + dir2) * vec);
|
||||
@@ -3996,7 +3996,7 @@ double ViewProviderSketch::getRotation(SbVec3f pos0, SbVec3f pos1) const
|
||||
getCoordsOnSketchPlane(pos0, vol.getProjectionDirection(), x0, y0);
|
||||
getCoordsOnSketchPlane(pos1, vol.getProjectionDirection(), x1, y1);
|
||||
|
||||
return -atan2((y1 - y0), (x1 - x0)) * 180 / M_PI;
|
||||
return -atan2((y1 - y0), (x1 - x0)) * 180 / std::numbers::pi;
|
||||
}
|
||||
catch (const Base::ZeroDivisionError&) {
|
||||
return 0;
|
||||
|
||||
@@ -237,7 +237,7 @@ TEST_F(SketchObjectTest, testGetPointFromGeomArcOfCircle)
|
||||
{
|
||||
// Arrange
|
||||
Base::Vector3d coordsCenter(1.0, 2.0, 0.0);
|
||||
double radius = 3.0, startParam = M_PI / 3, endParam = M_PI * 1.5;
|
||||
double radius = 3.0, startParam = std::numbers::pi / 3, endParam = std::numbers::pi * 1.5;
|
||||
Part::GeomArcOfCircle arcOfCircle;
|
||||
arcOfCircle.setCenter(coordsCenter);
|
||||
arcOfCircle.setRadius(radius);
|
||||
@@ -267,7 +267,7 @@ TEST_F(SketchObjectTest, testGetPointFromGeomArcOfEllipse)
|
||||
Base::Vector3d coordsCenter(1.0, 2.0, 0.0);
|
||||
double majorRadius = 4.0;
|
||||
double minorRadius = 3.0;
|
||||
double startParam = M_PI / 3, endParam = M_PI * 1.5;
|
||||
double startParam = std::numbers::pi / 3, endParam = std::numbers::pi * 1.5;
|
||||
Part::GeomArcOfEllipse arcOfEllipse;
|
||||
arcOfEllipse.setCenter(coordsCenter);
|
||||
arcOfEllipse.setMajorRadius(majorRadius);
|
||||
@@ -298,7 +298,7 @@ TEST_F(SketchObjectTest, testGetPointFromGeomArcOfHyperbola)
|
||||
Base::Vector3d coordsCenter(1.0, 2.0, 0.0);
|
||||
double majorRadius = 4.0;
|
||||
double minorRadius = 3.0;
|
||||
double startParam = M_PI / 3, endParam = M_PI * 1.5;
|
||||
double startParam = std::numbers::pi / 3, endParam = std::numbers::pi * 1.5;
|
||||
Part::GeomArcOfHyperbola arcOfHyperbola;
|
||||
arcOfHyperbola.setCenter(coordsCenter);
|
||||
arcOfHyperbola.setMajorRadius(majorRadius);
|
||||
@@ -330,7 +330,7 @@ TEST_F(SketchObjectTest, testGetPointFromGeomArcOfParabola)
|
||||
// Arrange
|
||||
Base::Vector3d coordsCenter(1.0, 2.0, 0.0);
|
||||
double focal = 3.0;
|
||||
double startParam = M_PI / 3, endParam = M_PI * 1.5;
|
||||
double startParam = std::numbers::pi / 3, endParam = std::numbers::pi * 1.5;
|
||||
Part::GeomArcOfParabola arcOfParabola;
|
||||
arcOfParabola.setCenter(coordsCenter);
|
||||
arcOfParabola.setFocal(focal);
|
||||
|
||||
@@ -846,7 +846,7 @@ TEST_F(SketchObjectTest, testJoinCurves)
|
||||
// Arrange
|
||||
// Make two curves
|
||||
Base::Vector3d coordsCenter(0.0, 0.0, 0.0);
|
||||
double radius = 3.0, startParam = M_PI / 2, endParam = M_PI;
|
||||
double radius = 3.0, startParam = std::numbers::pi / 2, endParam = std::numbers::pi;
|
||||
Part::GeomArcOfCircle arcOfCircle;
|
||||
arcOfCircle.setCenter(coordsCenter);
|
||||
arcOfCircle.setRadius(radius);
|
||||
@@ -877,7 +877,7 @@ TEST_F(SketchObjectTest, testJoinCurvesWhenTangent)
|
||||
// Arrange
|
||||
// Make two curves
|
||||
Base::Vector3d coordsCenter(0.0, 0.0, 0.0);
|
||||
double radius = 3.0, startParam = M_PI / 2, endParam = M_PI;
|
||||
double radius = 3.0, startParam = std::numbers::pi / 2, endParam = std::numbers::pi;
|
||||
Part::GeomArcOfCircle arcOfCircle;
|
||||
arcOfCircle.setCenter(coordsCenter);
|
||||
arcOfCircle.setRadius(radius);
|
||||
|
||||
@@ -56,7 +56,7 @@ void setupArcOfCircle(Part::GeomArcOfCircle& arcOfCircle)
|
||||
{
|
||||
Base::Vector3d coordsCenter(1.0, 2.0, 0.0);
|
||||
double radius = 3.0;
|
||||
double startParam = M_PI / 3, endParam = M_PI * 1.5;
|
||||
double startParam = std::numbers::pi / 3, endParam = std::numbers::pi * 1.5;
|
||||
arcOfCircle.setCenter(coordsCenter);
|
||||
arcOfCircle.setRadius(radius);
|
||||
arcOfCircle.setRange(startParam, endParam, true);
|
||||
@@ -77,7 +77,7 @@ void setupArcOfHyperbola(Part::GeomArcOfHyperbola& arcOfHyperbola)
|
||||
Base::Vector3d coordsCenter(1.0, 2.0, 0.0);
|
||||
double majorRadius = 4.0;
|
||||
double minorRadius = 3.0;
|
||||
double startParam = M_PI / 3, endParam = M_PI * 1.5;
|
||||
double startParam = std::numbers::pi / 3, endParam = std::numbers::pi * 1.5;
|
||||
arcOfHyperbola.setCenter(coordsCenter);
|
||||
arcOfHyperbola.setMajorRadius(majorRadius);
|
||||
arcOfHyperbola.setMinorRadius(minorRadius);
|
||||
@@ -88,7 +88,7 @@ void setupArcOfParabola(Part::GeomArcOfParabola& aop)
|
||||
{
|
||||
Base::Vector3d coordsCenter(1.0, 2.0, 0.0);
|
||||
double focal = 3.0;
|
||||
double startParam = -M_PI * 1.5, endParam = M_PI * 1.5;
|
||||
double startParam = -std::numbers::pi * 1.5, endParam = std::numbers::pi * 1.5;
|
||||
aop.setCenter(coordsCenter);
|
||||
aop.setFocal(focal);
|
||||
aop.setRange(startParam, endParam, true);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -54,8 +55,8 @@ TEST_F(ConstraintsTest, tangentBSplineAndArc) // NOLINT
|
||||
arcEnd.y = &arcEndY;
|
||||
arcCenter.x = &arcCenterX;
|
||||
arcCenter.y = &arcCenterY;
|
||||
double arcRadius = 5.0, arcStartAngle = 0.0, arcEndAngle = M_PI / 2;
|
||||
double desiredAngle = M_PI;
|
||||
double arcRadius = 5.0, arcStartAngle = 0.0, arcEndAngle = std::numbers::pi / 2;
|
||||
double desiredAngle = std::numbers::pi;
|
||||
double bSplineStartX = 0.0, bSplineEndX = 16.0;
|
||||
double bSplineStartY = 10.0, bSplineEndY = -10.0;
|
||||
GCS::Point bSplineStart, bSplineEnd;
|
||||
|
||||
Reference in New Issue
Block a user