public void TestNormMap4() { double start = 315.0; double stop = 225.0; Assert.AreEqual(0.0, CircularMath.NormMap(start, stop, -45.0)); Assert.AreEqual(0.5, CircularMath.NormMap(start, stop, 90.0)); Assert.AreEqual(1.0, CircularMath.NormMap(start, stop, 225.0)); Assert.AreEqual(double.NaN, CircularMath.NormMap(start, stop, 230.0)); Assert.AreEqual(double.NaN, CircularMath.NormMap(start, stop, -55.0)); }
public void TestNormMap1() { double start = 0.0; double stop = 180.0; Assert.AreEqual(0.0, CircularMath.NormMap(start, stop, 0.0)); Assert.AreEqual(0.5, CircularMath.NormMap(start, stop, 90.0)); Assert.AreEqual(1.0, CircularMath.NormMap(start, stop, 180.0)); Assert.AreEqual(double.NaN, CircularMath.NormMap(start, stop, 190.0)); Assert.AreEqual(double.NaN, CircularMath.NormMap(start, stop, -10.0)); }
public void TestNormMap2() { double start = 90.0; double stop = 270.0; Assert.AreEqual(0.0, CircularMath.NormMap(start, stop, 90.0)); Assert.AreEqual(0.5, CircularMath.NormMap(start, stop, 180.0)); Assert.AreEqual(1.0, CircularMath.NormMap(start, stop, 270.0)); Assert.AreEqual(double.NaN, CircularMath.NormMap(start, stop, 280.0)); Assert.AreEqual(double.NaN, CircularMath.NormMap(start, stop, 80.0)); }
private void UpdateSelectorFromPoint(Point point) { // Calculate angle from point (0..360) double angle = CircularMath.AngleFromPoint(point, CalculateCenter(this.ArcOffset)); // Convert to a normalized value between 0.0 and 1.0 double normAngle = CircularMath.NormMap(this.ArcStartAngle, this.ArcStopAngle, angle); // And update the value if (!double.IsNaN(normAngle)) { double value = normAngle * (this.Maximum - this.Minimum) + this.Minimum; this.Value = value; UpdateSelector(); } }