Commit f2927940 authored by kraus's avatar kraus
Browse files

change sign such that the absolute value of the amplitude is lowered if the...

change sign such that the absolute value of the amplitude is lowered if the bending angle is too big and increased if it's too small
parent 664fd16e
...@@ -692,31 +692,22 @@ void Bend2D::findBendStrength() { ...@@ -692,31 +692,22 @@ void Bend2D::findBendStrength() {
if (error < tolerance) if (error < tolerance)
return; return;
double fieldStep = estimateFieldAdjustmentStep(actualBendAngle); double fieldStep = std::copysign(1.0, fieldAmplitude_m) * std::abs(estimateFieldAdjustmentStep(actualBendAngle));
double amplitude1 = fieldAmplitude_m; double amplitude1 = fieldAmplitude_m;
double amplitude2 = amplitude1;
double bendAngle1 = actualBendAngle; double bendAngle1 = actualBendAngle;
double bendAngle2 = bendAngle1;
double amplitude2 = fieldAmplitude_m + fieldStep;
fieldAmplitude_m = amplitude2; int stepSign = std::abs(bendAngle1) > std::abs(angle_m) ? -1: 1;
double bendAngle2 = calculateBendAngle(); while (true) {
amplitude1 = amplitude2;
if (std::abs(bendAngle1) > std::abs(angle_m)) { bendAngle1 = bendAngle2;
while (std::abs(bendAngle2) > std::abs(angle_m)) {
amplitude1 = amplitude2; amplitude2 += stepSign * fieldStep;
bendAngle1 = bendAngle2; fieldAmplitude_m = amplitude2;
bendAngle2 = calculateBendAngle();
amplitude2 += fieldStep; if (stepSign * (std::abs(bendAngle2) - std::abs(angle_m)) > 0) {
fieldAmplitude_m = amplitude2; break;
bendAngle2 = calculateBendAngle();
}
} else {
while (std::abs(bendAngle2) < std::abs(angle_m)) {
amplitude1 = amplitude2;
bendAngle1 = bendAngle2;
amplitude2 += fieldStep;
fieldAmplitude_m = amplitude2;
bendAngle2 = calculateBendAngle();
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment