public VectorI2 GetOffset(VectorI2 radius) { return(new VectorI2( source.GetOffset(radius.x), source.GetOffset(radius.y) )); }
static public bool IsCardinallyAdjacent(this VectorI2 item, VectorI2 other) { if (item.x == other.x) { if (item.y == other.y - 1) { return(true); } if (item.y == other.y + 1) { return(true); } } if (item.y == other.y) { if (item.x == other.x - 1) { return(true); } if (item.x == other.x + 1) { return(true); } } return(false); }
public VectorI2 GetMagnitude(VectorI2 m) { return(new VectorI2( source.GetMagnitude(m.x), source.GetMagnitude(m.y) )); }
public VectorI2 GetBetween(VectorI2 a, VectorI2 b) { return(new VectorI2( source.GetBetween(a.x, b.x), source.GetBetween(a.y, b.y) )); }
static public RectI2 CreateStrictMinMaxRectI2(VectorI2 min, VectorI2 max) { RectI2 rect; TryCreateStrictMinMaxRectI2(min, max, out rect); return(rect); }
static public IEnumerable <IEnumerable <VectorI2> > TraverseEdges(this IGrid <bool> item, int maximum_gap) { VectorI2 point; IGrid <bool> edges = item.ConvertToStrictEdges().ToGrid(); int width = edges.GetWidth(); int height = edges.GetHeight(); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { point = new VectorI2(x, y); if (edges.Get(point)) { List <VectorI2> points = new List <VectorI2>(); do { edges.SetDropped(point, false); points.Add(point); }while (point.GetRadiating(maximum_gap).TryFindFirst(p => edges.Get(p), out point)); if (points.Count >= 3) { yield return(points); } } } } }
public VectorI2 GetVariance(VectorI2 center, VectorI2 radius) { return(new VectorI2( source.GetVariance(center.x, radius.x), source.GetVariance(center.y, radius.y) )); }
static public bool IsBoundBelow(this VectorI2 item, VectorI2 value) { if (item.x <= value.x && item.y <= value.y) { return(true); } return(false); }
static public bool IsCardinallyOrOrdinallyAdjacent(this VectorI2 item, VectorI2 other) { if (item.IsCardinallyAdjacent(other) || item.IsOrdinallyAdjacent(other)) { return(true); } return(false); }
static public int GetMagnitudeMinComponent(this VectorI2 item) { if (item.x.GetAbs() < item.y.GetAbs()) { return(item.x); } return(item.y); }
static public bool IsCardinallyAdjacent(this IEnumerable <VectorI2> item, VectorI2 point) { if (item.GetCardinallyAdjacent(point).IsNotEmpty()) { return(true); } return(false); }
static public bool IsBoundAbove(this VectorI2 item, VectorI2 value) { if (item.x >= value.x && item.y >= value.y) { return(true); } return(false); }
static public IEnumerable <VectorI2> GetCardinalNeighbors(this VectorI2 item) { yield return(new VectorI2(item.x, item.y - 1)); yield return(new VectorI2(item.x - 1, item.y)); yield return(new VectorI2(item.x + 1, item.y)); yield return(new VectorI2(item.x, item.y + 1)); }
static public bool TryCreateStrictMinMaxRectI2(VectorI2 min, VectorI2 max, out RectI2 rect) { if (min.IsBoundBelow(max)) { rect = new RectI2(min, max); return(true); } rect = RectI2.ZERO; return(false); }
static public bool Contains(this RectI2 item, VectorI2 point) { if (point.IsBoundAbove(item.min)) { if (point.IsBoundBelow(item.max)) { return(true); } } return(false); }
static public bool IsBoundBetween(this VectorI2 item, VectorI2 value1, VectorI2 value2) { VectorI2 lower; VectorI2 upper; value1.Order(value2, out lower, out upper); if (item.IsBoundAbove(lower) && item.IsBoundBelow(upper)) { return(true); } return(false); }
static public void AddRectangle(this ICollection <VectorI2> item, VectorI2 point1, VectorI2 point2) { VectorI2 lower; VectorI2 upper; point1.Order(point2, out lower, out upper); for (int x = lower.x; x <= upper.x; x++) { for (int y = lower.y; y <= upper.y; y++) { item.Add(new VectorI2(x, y)); } } }
static public void Order(this VectorI2 item, VectorI2 input, out VectorI2 lower, out VectorI2 upper) { int x_min; int x_max; item.x.Order(input.x, out x_min, out x_max); int y_min; int y_max; item.y.Order(input.y, out y_min, out y_max); lower = new VectorI2(x_min, y_min); upper = new VectorI2(x_max, y_max); }
static public IEnumerable <HashSet <VectorI2> > GetCardinallyContinousAreas(this HashSet <VectorI2> item) { HashSet <VectorI2> copy = item.ToHashSet(); List <HashSet <VectorI2> > areas = new List <HashSet <VectorI2> >(); while (copy.IsNotEmpty()) { VectorI2 point = copy.GetFirst(); HashSet <VectorI2> area = copy.GetCardinallyContinousAreaAt(point); areas.Add(area); copy.ExceptWith(area); } return(areas); }
static public IEnumerable <VectorI2> GetRadiating(this VectorI2 item, int radius) { return(RadiatingWalker.Iterator(radius).Convert(d => item + d)); }
public RectI2(VectorI2 np1, VectorI2 np2) { np1.Order(np2, out min, out max); }
public RandVectorI2Box_Between(VectorI2 na, VectorI2 nb, RandVectorI2Source s) : base(s) { a = na; b = nb; }
static public bool IsIndexValid <T>(this IGrid <T> item, VectorI2 index) { return(item.IsIndexValid <T>(index.x, index.y)); }
static public void Add <T>(this IGrid <List <T> > item, VectorI2 index, T value) { item.Add(index.x, index.y, value); }
public RandVectorI2Box_Between(VectorI2 na, VectorI2 nb) : this(na, nb, RandVectorI2.SOURCE) { }
static public T GetLooped <T>(this IGrid <T> item, VectorI2 index) { return(item.GetLooped <T>(index.x, index.y)); }
static public void SetLooped <T>(this IGrid <T> item, VectorI2 index, T value) { item.SetLooped <T>(index.x, index.y, value); }
static public IGrid <T> BoundSub <T>(this IGrid <T> item, VectorI2 index, VectorI2 size) { return(item.BoundSubSection <T>(index, index + size)); }
static public IGrid <T> BoundSubArea <T>(this IGrid <T> item, VectorI2 center, int radius) { return(item.BoundSubArea <T>(center.x, center.y, radius)); }
static public IGrid <T> BoundSubSection <T>(this IGrid <T> item, VectorI2 lower, VectorI2 upper) { return(item.BoundSubSection(lower.x, lower.y, upper.x, upper.y)); }