public bool OverlapsWith(Projection other) { return (this.Min < other.Min && other.Min < this.Max) || (this.Min < other.Max && other.Max < this.Max) || (other.Min < this.Min && this.Min < other.Max) || (other.Min < this.Max && this.Max < other.Max); }
public float CalculateOverlap(Projection other) { float overlap = Math.Min(this.Max - other.Min, other.Max - this.Min); overlap = Math.Min(overlap, this.Max - this.Min); overlap = Math.Min(overlap, other.Max - other.Min); //handle containment offset if (this.Min <= other.Min && this.Max >= other.Max || other.Min <= this.Min && other.Max >= this.Max) { float mins, maxes; mins = Math.Abs(this.Min - other.Min); maxes = Math.Abs(this.Max - other.Max); if (mins < maxes) overlap += mins; else overlap += maxes; } return overlap; }