using Microsoft.Msagl.Core.Geometry; namespace Microsoft.Msagl.Layout.LargeGraphLayout { /// /// represents a range of doubles /// public class Interval { /// /// constructor /// /// /// public Interval(double start, double end) { Start = start; End = end; } /// /// /// /// /// public Interval(Interval a, Interval b) { Start = a.Start; End = a.End; Add(b.Start); Add(b.End); } /// /// expanding the range to hold v /// /// public void Add(double v) { if (Start > v) Start = v; if (End < v) End = v; } /// /// /// public double Start { get; set; } /// /// /// public double End { get; set; } /// /// the length /// public double Length { get { return End - Start; } } /// /// return true if the value is inside the range /// /// /// public bool Contains(double v) { return Start <= v && v <= End; } /// /// bringe v into the range /// /// /// public double GetInRange(double v) { return v < Start ? Start : (v > End ? End : v); } /// /// returns true if and only if two intervals are intersecting /// /// /// public bool Intersects(Interval other) { if (other.Start > End + ApproximateComparer.DistanceEpsilon) return false; return !(other.End < Start - ApproximateComparer.DistanceEpsilon); } } }