/// <summary>Returns the union of two Coord2Ranges as a list of all covered Coord2s.</summary> public static ListSet <Coord2> Union(Coord2Range a, Coord2Range b) { ListSet <Coord2> union = new ListSet <Coord2>(); union.AddRange(a.coords); union.AddRange(b.coords); return(union); }
public override bool Equals(object obj) { if (obj is Coord2Range) { Coord2Range coord_range = (Coord2Range)obj; return(xMin == coord_range.xMin && xMax == coord_range.xMax && yMin == coord_range.yMin && yMax == coord_range.yMax); } return(false); }
/// <summary>Change a Coord2Range that is relative to some direction into a global Coord2Range relative to 'up'.</summary> public Coord2Range RelativeToGlobal(CardinalDir forDirection) { Coord2Range rotated = this; for (int i = 0; i < (int)forDirection; i++) { rotated = rotated.rotatedClockwise; } return(rotated); }
public bool Equals(Coord2Range coord_range) { return(xMin == coord_range.xMin && xMax == coord_range.xMax && yMin == coord_range.yMin && yMax == coord_range.yMax); }
/// <summary>Returns the intersection of two Coord2Ranges.</summary> public static Coord2Range Intersection(Coord2Range a, Coord2Range b) { return(new Coord2Range(Mathf.Max(a.xMin, b.xMin), Mathf.Min(a.xMax, b.xMax), Mathf.Max(a.yMin, b.yMin), Mathf.Min(a.yMax, b.yMax))); }
/// <summary>Returns a Coord2Range whose minimums are increased and maximums decreased by another Coord2Range.</summary> public Coord2Range Shrink(Coord2Range other) { return(new Coord2Range(xMin + other.xMin, xMax - other.xMax, yMin + other.yMin, yMax - other.yMax)); }