All files Interval.ts

83.33% Statements 10/12
75% Branches 3/4
75% Functions 3/4
81.82% Lines 9/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 471x 1x         1760x 1760x                                             1x               1x 12x 12x           1x
import {S2} from "./S2";
export abstract class Interval {
  public lo:decimal.Decimal;
  public hi:decimal.Decimal;
 
  constructor(lo:number|decimal.Decimal, hi:number|decimal.Decimal) {
    this.lo = S2.toDecimal(lo);
    this.hi = S2.toDecimal(hi);
  }
 
  /** Return true if the interval is empty, i.e. it contains no points. */
 
  public abstract isEmpty():boolean;
 
  /**
   * Return the center of the interval. For empty intervals, the result is
   * arbitrary.
   */
  public abstract getCenter():decimal.Decimal;
 
  /**
   * Return the length of the interval. The length of an empty interval is
   * negative.
   */
  public abstract getLength():decimal.Decimal;
 
  public abstract contains(p:number|decimal.Decimal):boolean;
 
  public abstract interiorContains(p:number|decimal.Decimal):boolean;
 
  public  toString():string {
    return "[" + this.lo.toString() + ", " + this.hi.toString() + "]";
  }
 
 
  /**
   * Return true if two intervals contains the same set of points.
   */
  public equals(that:any):boolean {
    Eif (typeof(that) === typeof(this)) {
      return this.lo .eq(that.lo) && this.hi.eq(that.hi);
    }
    return false;
  }
 
 
}