Пример #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)));
 }