public RectBox CreateIntersection(RectBox rectBox) { RectBox dest = new RectBox(); dest.Intersection(rectBox); Intersect(this, rectBox, dest); return(dest); }
public RectBox Copy(RectBox other) { this.x = other.x; this.y = other.y; this.width = other.width; this.height = other.height; return(this); }
public RectBox Sub(RectBox view) { if (view == null) { return(Cpy()); } return(new RectBox(x - view.x, y - view.y, width - view.width, height - view.height)); }
public RectBox Inc(RectBox view) { if (view == null) { return(Cpy()); } return(new RectBox(x + view.x, y + view.y, width + view.width, height + view.height)); }
public RectBox Mul(RectBox view) { if (view == null) { return(Cpy()); } return(new RectBox(x * view.x, y * view.y, width * view.width, height * view.height)); }
public RectBox Div(RectBox view) { if (view == null) { return(Cpy()); } return(new RectBox(x / view.x, y / view.y, width / view.width, height / view.height)); }
public static RectBox Inflate(RectBox src, int xScale, int yScale) { float destWidth = src.width + xScale; float destHeight = src.height + yScale; float destX = src.x - xScale / 2; float destY = src.y - yScale / 2; return(new RectBox(destX, destY, destWidth, destHeight)); }
public RectBox GetIntersection(RectBox rect) { int x1 = (int)MathUtils.Max(x, rect.x); int x2 = (int)MathUtils.Min(x + width, rect.x + rect.width); int y1 = (int)MathUtils.Max(y, rect.y); int y2 = (int)MathUtils.Min(y + height, rect.y + rect.height); return(new RectBox(x1, y1, x2 - x1, y2 - y1)); }
public bool Intersects(RectBox other) { RectBox box = other; if (box.Contains(x + boundingCircleRadius, y + boundingCircleRadius)) { return(true); } return(CollideBounds(other)); }
public RectBox Add(RectBox r) { int tx2 = this.width; int ty2 = this.height; if ((tx2 | ty2) < 0) { SetBounds(r.x, r.y, r.width, r.height); } int rx2 = r.width; int ry2 = r.height; if ((rx2 | ry2) < 0) { return(this); } float tx1 = this.x; float ty1 = this.y; tx2 += (int)tx1; ty2 += (int)ty1; float rx1 = r.x; float ry1 = r.y; rx2 += (int)rx1; ry2 += (int)ry1; if (tx1 > rx1) { tx1 = rx1; } if (ty1 > ry1) { ty1 = ry1; } if (tx2 < rx2) { tx2 = rx2; } if (ty2 < ry2) { ty2 = ry2; } tx2 -= (int)tx1; ty2 -= (int)ty1; if (tx2 > Integer.MAX_VALUE_JAVA) { tx2 = Integer.MAX_VALUE_JAVA; } if (ty2 > Integer.MAX_VALUE_JAVA) { ty2 = Integer.MAX_VALUE_JAVA; } SetBounds(tx1, ty1, tx2, ty2); return(this); }
public static RectBox Intersect(RectBox src1, RectBox src2, RectBox dest) { if (dest == null) { dest = new RectBox(); } float x1 = MathUtils.Max(src1.GetMinX(), src2.GetMinX()); float y1 = MathUtils.Max(src1.GetMinY(), src2.GetMinY()); float x2 = MathUtils.Min(src1.GetMaxX(), src2.GetMaxX()); float y2 = MathUtils.Min(src1.GetMaxY(), src2.GetMaxY()); dest.SetBounds(x1, y1, x2 - x1, y2 - y1); return(dest); }
public RectBox Normalize(RectBox r) { if (r.width < 0) { r.width = MathUtils.Abs(r.width); r.x -= r.width; } if (r.height < 0) { r.height = MathUtils.Abs(r.height); r.y -= r.height; } return(this); }
public static RectBox GetIntersection(RectBox a, RectBox b) { float a_x = a.GetX(); float a_r = a.GetRight(); float a_y = a.GetY(); float a_t = a.GetBottom(); float b_x = b.GetX(); float b_r = b.GetRight(); float b_y = b.GetY(); float b_t = b.GetBottom(); float i_x = MathUtils.Max(a_x, b_x); float i_r = MathUtils.Min(a_r, b_r); float i_y = MathUtils.Max(a_y, b_y); float i_t = MathUtils.Min(a_t, b_t); return(i_x < i_r && i_y < i_t ? new RectBox(i_x, i_y, i_r - i_x, i_t - i_y) : null); }
public bool CollideBounds(RectBox size) { float radiusDouble = boundingCircleRadius * boundingCircleRadius; if (x < size.GetX() - boundingCircleRadius) { return(false); } if (x > size.GetBottom() + boundingCircleRadius) { return(false); } if (y < size.GetY() - boundingCircleRadius) { return(false); } if (y > size.GetBottom() + boundingCircleRadius) { return(false); } if (x < size.GetX() && y < size.GetY() && MathUtils.Distance(x - size.GetX(), y - size.GetY()) > radiusDouble) { return(false); } if (x > size.GetRight() && y < size.GetY() && MathUtils.Distance(x - size.GetRight(), y - size.GetY()) > radiusDouble) { return(false); } if (x < size.GetX() && y > size.GetBottom() && MathUtils.Distance(x - size.GetX(), y - size.GetBottom()) > radiusDouble) { return(false); } if (x > size.GetRight() && y > size.GetBottom() && MathUtils.Distance(x - size.GetRight(), y - size.GetBottom()) > radiusDouble) { return(false); } return(true); }
public static RectBox GetIntersection(RectBox a, RectBox b, RectBox result) { float a_x = a.GetX(); float a_r = a.GetRight(); float a_y = a.GetY(); float a_t = a.GetBottom(); float b_x = b.GetX(); float b_r = b.GetRight(); float b_y = b.GetY(); float b_t = b.GetBottom(); float i_x = MathUtils.Max(a_x, b_x); float i_r = MathUtils.Min(a_r, b_r); float i_y = MathUtils.Max(a_y, b_y); float i_t = MathUtils.Min(a_t, b_t); if (i_x < i_r && i_y < i_t) { result.SetBounds(i_x, i_y, i_r - i_x, i_t - i_y); return(result); } return(null); }
public bool Intersects(RectBox rect) { if (rect == null) { return(false); } float x1 = start.GetX(); float y1 = start.GetY(); float x2 = end.GetX() + start.GetX(); float y2 = end.GetY() + start.GetY(); float bx1 = rect.x; float by1 = rect.y; float bx2 = rect.GetRight(); float by2 = rect.GetBottom(); float t = 0; if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) { return(true); } if (x1 < bx1 && x2 >= bx1) { t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1); if (t > by1 && t <= by2) { return(rect.Intersects(this)); } } else if (x1 > bx2 && x2 <= bx2) { t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1); if (t >= by1 && t <= by2) { return(rect.Intersects(this)); } } if (y1 < by1 && y2 >= by1) { t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1); if (t >= bx1 && t <= bx2) { return(rect.Intersects(this)); } } else if (y1 > by2 && y2 <= by2) { t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1); if (t >= bx1 && t <= bx2) { return(rect.Intersects(this)); } } return(false); }
public bool Intersects(RectBox rect) { return(Intersects(rect.x, rect.y, rect.width, rect.height)); }
public RectBox SetBounds(RectBox rect) { SetBounds(rect.x, rect.y, rect.width, rect.height); return(this); }
public RectBox(RectBox rect) { SetBounds(rect.x, rect.y, rect.width, rect.height); }
public RectBox SetLocation(RectBox r) { this.x = r.x; this.y = r.y; return(this); }
public bool Overlaps(RectBox rectangle) { return(!(x > rectangle.x + rectangle.width || x + width < rectangle.x || y > rectangle.y + rectangle.height || y + height < rectangle.y)); }
public bool Contains(RectBox rect) { return(Contains(rect.x, rect.y, rect.width, rect.height)); }
public RectBox Intersection(RectBox rect) { return(Intersection(rect.x, rect.y, rect.width, rect.height)); }
public RectBox Union(RectBox rect) { return(Union(rect.x, rect.y, rect.width, rect.height)); }