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() {
if (error < tolerance)
return;
double fieldStep = estimateFieldAdjustmentStep(actualBendAngle);
double fieldStep = std::copysign(1.0, fieldAmplitude_m) * std::abs(estimateFieldAdjustmentStep(actualBendAngle));
double amplitude1 = fieldAmplitude_m;
double amplitude2 = amplitude1;
double bendAngle1 = actualBendAngle;
double amplitude2 = fieldAmplitude_m + fieldStep;
fieldAmplitude_m = amplitude2;
double bendAngle2 = calculateBendAngle();
if (std::abs(bendAngle1) > std::abs(angle_m)) {
while (std::abs(bendAngle2) > std::abs(angle_m)) {
amplitude1 = amplitude2;
bendAngle1 = bendAngle2;
amplitude2 += fieldStep;
fieldAmplitude_m = amplitude2;
bendAngle2 = calculateBendAngle();
}
} else {
while (std::abs(bendAngle2) < std::abs(angle_m)) {
amplitude1 = amplitude2;
bendAngle1 = bendAngle2;
amplitude2 += fieldStep;
fieldAmplitude_m = amplitude2;
bendAngle2 = calculateBendAngle();
double bendAngle2 = bendAngle1;
int stepSign = std::abs(bendAngle1) > std::abs(angle_m) ? -1: 1;
while (true) {
amplitude1 = amplitude2;
bendAngle1 = bendAngle2;
amplitude2 += stepSign * fieldStep;
fieldAmplitude_m = amplitude2;
bendAngle2 = calculateBendAngle();
if (stepSign * (std::abs(bendAngle2) - std::abs(angle_m)) > 0) {
break;
}
}
......
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