예제 #1
0
 public static IEnumerable <double> GetTicsInOrder(this RealInterval realInterval, int segmentCount)
 {
     for (int i = 0; i < segmentCount + 1; i++)
     {
         yield return(realInterval.GetTicValue(i, segmentCount));
     }
 }
예제 #2
0
        public static Rect ZoomBy(this Rect rect, double xZoom, double yZoom)
        {
            var xInterval = new RealInterval(rect.Left, rect.Right).ZoomBy(xZoom);
            var yInterval = new RealInterval(rect.Top, rect.Bottom).ZoomBy(yZoom);

            return(new Rect(xInterval.Min, yInterval.Min, xInterval.Span(), yInterval.Span()));
        }
예제 #3
0
 public static string BasicRangeFormat(this RealInterval realInterval, string label, string format)
 {
     if (string.IsNullOrEmpty(format))
     {
         return(string.Format("{0}: {1} - {2}", label, realInterval.Min, realInterval.Max));
     }
     return(string.Format("{0}: {1} - {2}", label, realInterval.Min.ToString(format), realInterval.Max.ToString(format)));
 }
예제 #4
0
 public static RealInterval AdjustBy(this RealInterval interval, double minDelta, double maxDelta)
 {
     return(new RealInterval
            (
                interval.Min + minDelta,
                interval.Max + maxDelta
            ));
 }
 public RealInterval MapRealInterval(RealInterval value)
 {
     if (Double.IsNaN(Slope))
     {
         return(RealInterval.Empty);
     }
     return(new RealInterval(MapDouble(value.Min), MapDouble(value.Max)));
 }
예제 #6
0
 public static XElement ToXml(this RealInterval realInterval)
 {
     return(new XElement
            (
                "RealInterval",
                new XElement("Min", realInterval.Min),
                new XElement("Max", realInterval.Max)
            ));
 }
예제 #7
0
 /// <summary>
 /// Zooms out for factor > 1
 /// </summary>
 /// <param name="interval"></param>
 /// <param name="factor"></param>
 /// <returns></returns>
 public static RealInterval ZoomBy(this RealInterval interval, double factor)
 {
     factor = Math.Abs(factor);
     return(new RealInterval
            (
                interval.Center() - interval.Span() * factor / 2,
                interval.Center() + interval.Span() * factor / 2
            ));
 }
예제 #8
0
 public static IEnumerable <RealInterval> SplitToEvenIntervals(this RealInterval realInterval, int segmentCount)
 {
     for (int i = 0; i < segmentCount; i++)
     {
         yield return(new RealInterval
                      (
                          realInterval.GetTicValue(i, segmentCount),
                          realInterval.GetTicValue(i + 1, segmentCount)
                      ));
     }
 }
예제 #9
0
 public static IEnumerable <double> Points(this RealInterval realInterval)
 {
     if (!double.IsNaN(realInterval.Min))
     {
         yield return(realInterval.Min);
     }
     if (!double.IsNaN(realInterval.Max))
     {
         yield return(realInterval.Max);
     }
 }
예제 #10
0
 public static double Span(this RealInterval ri)
 {
     if (ri == null)
     {
         return(Double.NaN);
     }
     if (Double.IsNaN(ri.Min) || Double.IsNaN(ri.Max))
     {
         return(Double.NaN);
     }
     return(ri.Max - ri.Min);
 }
예제 #11
0
 public static RealInterval Pad(this RealInterval realInterval, double leftSide, double rightSide)
 {
     return(new RealInterval(realInterval.Min - leftSide, realInterval.Max + rightSide));
 }
예제 #12
0
 public static double Center(this RealInterval ri)
 {
     return((ri.Min + ri.Max) / 2);
 }
예제 #13
0
 public static RealInterval Offset(this RealInterval realInterval, double delta)
 {
     return(new RealInterval(realInterval.Min + delta, realInterval.Max + delta));
 }
예제 #14
0
 public static double GetTicValue(this RealInterval realInterval, int tic, int segmentCount)
 {
     return(realInterval.Min + (realInterval.Span() * tic) / (segmentCount));
 }
예제 #15
0
 public static IEnumerable <Rect> PillarProduct(this RealInterval vertVal, IEnumerable <RealInterval> horVals)
 {
     return(horVals.Select(mzBand => new Rect(mzBand.Min, vertVal.Min, mzBand.Span(), vertVal.Span())));
 }
예제 #16
0
 public static IEnumerable <Rect> SandwichProduct(this RealInterval horVal, IEnumerable <RealInterval> vertVals)
 {
     return(vertVals.Select(mzBand => new Rect(horVal.Min, mzBand.Min, horVal.Span(), mzBand.Span())));
 }
 public RealIntervalLinearMap(RealInterval domain, RealInterval range)
 {
     Domain = domain;
     Range  = range;
 }
예제 #18
0
 public static string BracketFormat(this RealInterval realInterval, string numberFormat)
 {
     return(String.Format("[{0}-{1}]", realInterval.Min.ToString(numberFormat),
                          realInterval.Max.ToString(numberFormat)));
 }