Exemplo n.º 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));
     }
 }
Exemplo n.º 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()));
        }
Exemplo n.º 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)));
 }
Exemplo n.º 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)));
 }
Exemplo n.º 6
0
 public static XElement ToXml(this RealInterval realInterval)
 {
     return(new XElement
            (
                "RealInterval",
                new XElement("Min", realInterval.Min),
                new XElement("Max", realInterval.Max)
            ));
 }
Exemplo n.º 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
            ));
 }
Exemplo n.º 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)
                      ));
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 11
0
 public static RealInterval Pad(this RealInterval realInterval, double leftSide, double rightSide)
 {
     return(new RealInterval(realInterval.Min - leftSide, realInterval.Max + rightSide));
 }
Exemplo n.º 12
0
 public static double Center(this RealInterval ri)
 {
     return((ri.Min + ri.Max) / 2);
 }
Exemplo n.º 13
0
 public static RealInterval Offset(this RealInterval realInterval, double delta)
 {
     return(new RealInterval(realInterval.Min + delta, realInterval.Max + delta));
 }
Exemplo n.º 14
0
 public static double GetTicValue(this RealInterval realInterval, int tic, int segmentCount)
 {
     return(realInterval.Min + (realInterval.Span() * tic) / (segmentCount));
 }
Exemplo n.º 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())));
 }
Exemplo n.º 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;
 }
Exemplo n.º 18
0
 public static string BracketFormat(this RealInterval realInterval, string numberFormat)
 {
     return(String.Format("[{0}-{1}]", realInterval.Min.ToString(numberFormat),
                          realInterval.Max.ToString(numberFormat)));
 }