using System;
namespace Framework.Geometry.Lines.Intersection {
  /// Contact invervals between a line and another shape
  public struct LineContacts {
    /// A line contacts instance for reporting no contacts
    public static readonly LineContacts None = new LineContacts(float.NaN, float.NaN);
    /// Time the first contact was made
    public float EntryTime;
    /// Time the last contact occurred
    public float ExitTime;
    /// Initializes a new contact point
    /// Time the contact was made at
    public LineContacts(float touchTime) :
      this(touchTime, touchTime) { }
    /// Initializes a new contact point
    /// Time the first contact was made at
    /// Time the last contact has occured
    public LineContacts(float entryTime, float exitTime) {
      this.EntryTime = entryTime;
      this.ExitTime = exitTime;
    }
    /// Whether a contact is stored in the line contacts instance
    public bool HasContact {
      get { return (!float.IsNaN(this.EntryTime) && !float.IsNaN(this.ExitTime)); }
    }
    /// 
    ///   Determines whether this instance is identical to another instance
    /// 
    /// Other instance of compare against
    /// True if both instances are identical
    public override bool Equals(object otherObject) {
      if(!(otherObject is LineContacts)) {
        return false;
      }
      LineContacts other = (LineContacts)otherObject;
      return
        (this.EntryTime == other.EntryTime) &&
        (this.ExitTime == other.ExitTime);
    }
    /// Returns a hash code for the instance
    /// The instance's hash code
    public override int GetHashCode() {
      return this.EntryTime.GetHashCode() ^ this.ExitTime.GetHashCode();
    }
  }
} // namespace Framework.Geometry.Lines.Intersection