/// <summary>
        /// 判断两个区域是否相交。
        /// </summary>
        /// <param name="that">需要判断相交的另一个区域。</param>
        /// <returns>如果相交则返回 True,否则返回 False。</returns>
        public bool Intersect(Interval1D that)
        {
            if (this.Max < that.Min || that.Max < this.Min)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// 判断两个区间是否相等。
        /// </summary>
        /// <param name="obj">相比较的区间。</param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (obj.GetType() != this.GetType())
            {
                return(false);
            }
            Interval1D that = (Interval1D)obj;

            return(this.Min == that.Min && this.Max == that.Max);
        }
 /// <summary>
 /// 构造函数。
 /// </summary>
 /// <param name="x">x 轴上的范围。</param>
 /// <param name="y">y 轴上的范围。</param>
 public Interval2D(Interval1D x, Interval1D y)
 {
     this.X = x;
     this.Y = y;
 }
 /// <summary>
 /// 判断目标区间是否被本区间包含。
 /// </summary>
 /// <param name="that">需要判断是否被包含的区间。</param>
 /// <returns></returns>
 public bool Contains(Interval1D that)
 {
     return(this.Min < that.Min && this.Max > that.Max);
 }
Exemple #5
0
 /// <summary>
 /// 构造函数。
 /// </summary>
 /// <param name="x">x 轴上的范围。</param>
 /// <param name="y">y 轴上的范围。</param>
 public Interval2D(Interval1D x, Interval1D y)
 {
     X = x;
     Y = y;
 }