Commit 3346424c authored by Valérie Maquil's avatar Valérie Maquil

fixed how values are calculated

based on angle, lowerbound, upperbound and stepsize. 
parent bd393569
......@@ -141,14 +141,21 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
return;
}
// if (Double.isNaN(delta)) {
// delta = (tangibleObject.getAngle() + Math.PI) % (2 * Math.PI);
// }
angle = (lowerStopAngle + Math.PI + tangibleObject.getAngle()) % (2 * Math.PI);
// angle = (lowerStopAngle + tangibleObject.getAngle()) % (2 * Math.PI) - Math.PI;
if ((angle >= lowerStopAngle) && (angle <= upperStopAngle)) {
dialAngle = angle;
dialAngle = angle;
if ((angle < lowerStopAngle) || (angle > upperStopAngle)) {
double upperDist = Math.min(Math.abs(angle - upperStopAngle), Math.abs(angle + 2 * Math.PI - upperStopAngle));
double lowerDist = Math.min(Math.abs(angle - lowerStopAngle), Math.abs(angle - 2 * Math.PI - lowerStopAngle));
if (upperDist < lowerDist)
dialAngle = upperStopAngle;
else
dialAngle = lowerStopAngle;
}
angleChanged = true;
......@@ -231,7 +238,12 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
private void updateFromRotation(double angle) {
double value = lowerBound + (stepSize * Math.floor(((angle - lowerStopAngle) / stepAngle)));
// double value = lowerBound + (stepSize * Math.round(((angle - lowerStopAngle) /
// stepAngle)));
double numSteps = Math.round(((angle - lowerStopAngle) / stepAngle));
double value = lowerBound + (stepSize * numSteps);
if (value < this.lowerBound) {
value = this.lowerBound;
......@@ -241,6 +253,7 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
value = this.upperBound;
}
variable.setValue(value);
}
}
\ No newline at end of file
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