Данный отчёт сгенерирован 04.04.2023 06:21:13 UTC.
HTML версия (этот сайт) сгенерирован 04.04.2023 06:21:31 UTC.
Коммит: [bfeb65b9] add automatic zip creation 04.04.2023 06:21:13
HTML версия (этот сайт) сгенерирован 04.04.2023 06:21:31 UTC.
Коммит: [bfeb65b9] add automatic zip creation 04.04.2023 06:21:13
Задача: Перетин з Прямокутником
04.04.2023 06:21:13
Описание: Заданий клас
class BaseRect
{
protected double x;
protected double y;
protected double w;
protected double h;
public BaseRect(double x, double y, double w, double h)
{
this.x = x;
this.y = y;
this.h = h;
this.w = w;
}
}
x, y - координати верхнього лівого кута прямокутника, w і h - його ширина та висота. Система координат – екранна.
Сторони прямокутника паралельні до осей координат.
Додати в клас BaseRect метод bool Intersect(BaseRect other), який повертає true,
якщо прямокутники this і other мають загальну частину ненульової площі.
04.04.2023 06:21:13
Решений: 55
04.04.2023 06:21:13
Перетин з Прямокутником
04.04.2023 06:21:13
public bool Intersect(BaseRect other)
{
if(((other.x>this.x&&other.x< this.x+this.w)||(other.x+w>this.x&&other.x+w< this.x+this.w))&&((other.y>this.y&&other.y< this.y+this.h)||(other.y+other.h>this.y&&other.y+other.h< this.y+this.w))) return true;
return false;
}
public bool Intersect(BaseRect other)
{
return other.x > this.x - other.w
&& other.x < this.x + this.w
&& other.y > this.y - this.h
&& other.y < this.y + other.h;
}
public bool Intersect(BaseRect other)
{
return !(this.x + this.w - 1 < other.x ||
this.x > other.x + other.w - 1 ||
this.y > other.y + other.h - 1 ||
this.y + this.h - 1 < other.y
);
}
public bool Includes(double x, double y)
{
return x >= this.x && x <= this.x + w
&& y >= this.y && y <= this.y + h;
}
public bool Intersect(BaseRect other)
{
return other.Includes(x, y)
|| other.Includes(x + w, y)
|| other.Includes(x, y + h)
|| other.Includes(x + w, y + h);
}
public bool Intersect(BaseRect other)
{
double thisSum = (this.x + this.w)*(this.y + this.h);
double otherSum = (other.x + other.w)*(other.y + other.h);
return (thisSum == otherSum);
}
public bool Intersect(BaseRect other)
{
double thisRight = this.x + this.w;
double thisBottom = this.y + this.h;
double otherRight = other.x + other.w;
double otherBottom = other.y + other.h;
bool xOverlap = (this.x < other.x && thisRight > other.x) || (this.x >= other.x && this.x < otherRight);
bool yOverlap = (this.y < other.y && thisBottom > other.y) || (this.y >= other.y && this.y < otherBottom);
return xOverlap && yOverlap;
}
public bool Intersect(BaseRect other){
return true;
}
public bool Intersect(BaseRect other)
{
if (other.x + other.w < x || x + w < other.x)
return false;
if (other.y + other.h < y || y + h < other.y)
return false;
return true;
}
public bool Intersect(BaseRect other) => false;
public bool Intersect(BaseRect other)
{
if (this.x <= other.x && this.x + this.w >= other.x && this.y >= other.y && this.y - this.h <= other.y)
{
return true;
}
else if ((this.x <= other.x + other.w) && (this.x + this.w >= other.x + other.w) && (this.y >= other.y) && (this.y - this.h <= other.y))
{
return true;
}
else if (this.x <= other.x && this.x + this.w >= other.x && this.y >= other.y - other.h && this.y - this.h <= other.y - other.y)
{
return true;
}
else if (this.x <= other.x + other.w && this.x + this.w >= other.x + other.w && this.y >= other.y -other.h && this.y - this.h <= other.y - other.h)
{
return true;
}
else
{
return false;
}
}
public bool Intersect(BaseRect other){
return false;
}
public bool Intersect(BaseRect other)
{
return !(x + w < other.x || y < other.y - other.h || x > other.x + other.w || y - h > other.y);
}
public bool Intersect(BaseRect other)
{
return this.x < other.x+other.w && other.x < this.x+this.w && this.y < other.y+other.h && other.y < this.y+this.h;
}
public bool Intersect(BaseRect other) {
return other.x > x - other.w
&& other.x < x + w
&& other.y > y - h
&& other.y < y + other.h;
}
public bool Intersect(BaseRect other)
{
double thisX = this.x + this.w;
double thisY = this.y + this.h;
double otherX = other.x + other.w;
double otherY = other.y + other.h;
if (this.x < otherX && thisX > other.x && this.y < otherY && thisY > other.y)
{
return true;
}
else {return false;}
}
public bool Intersect(BaseRect other) {
return true;
}
public bool Intersect(BaseRect other)
{
bool inter_x = Math.Abs((x + w) - (other.x + other.w)) <= (w + other.w);
bool inter_y = Math.Abs((y + h) - (other.y + other.h)) <= (h + other.h);
return inter_x && inter_y;
}
public bool Intersect(BaseRect other){return other.h == h || other.w == w ? true: false;}
public bool Intersect(BaseRect other)
{
double x1 = x + w;
double y1 = y + h;
double x2 = other.x + other.w;
double y2 = other.y + other.h;
if (x > x2 || x1 < other.x || y > y2 || y1 < other.y)
{
return false;
}
return true;
}
public bool Intersect(BaseRect other)
{
for(double i1 = this.x; i1 < this.x + this.w; i1++)
{
for(double j1 = this.y; j1 < this.y + this.h; j1++)
{
for(double i2 = other.x; i2 < other.x + other.w; i2++)
{
for(double j2 = other.x; j2 < other.x + other.w; j2++)
if(i1 == i1 && j1 == j2) return true;
}
}
}
return false;
}
public bool Intersect(BaseRect other)
{
return (this.x + this.w < other.x || other.x + other.w < this.x) ||
(this.y - this.h > other.y || other.y - other.h > this.y);
}
public bool Intersect(BaseRect other) => this.x < other.x && other.x < (this.x+this.w) && this.y < other.y && other.y < (this.y+this.h) || other.x < this.x && this.x < (other.x+other.w) && other.y < this.y && this.y < (other.y+other.h);
public bool Intersect(BaseRect other){
return (x > this.x & x < this.x + this.w ? true : false & y > this.y & x < this.y+ this.h ? true : false);
}
public bool Intersect(BaseRect other)
{
double l = Math.Max(this.x ,other.x);
double r = Math.Max(this.x+this.w , other.x+other.w);
double b = Math.Max(this.y-h,other.y-h);
double t = Math.Max(this.y , other.y);
if (r-l < 0 || t-b < 0)
return false;
else
{
return true;
}
}
public bool Intersect(BaseRect other){
double x2 = this.x + this.w;
double y2 = this.y + this.h;
double otherX2 = other.x + other.w;
double otherY2 = other.y + other.h;
return this.x < otherX2 && x2 > other.x && this.y < otherY2 && y2 > other.y;
}
public bool Intersect(BaseRect other){
if(x + w < other.x || other.x + other.w < x){
return false;
}
if(y + h < other.y || other.y + other.h < y){
return false;
}
return true;
}
public bool Intersect(BaseRect other) {
if (this.Includes(other.x, other.y)){
return true;
}
if (this.Includes(other.x+other.w, other.y)) {
return true;
}
if (this.Includes(other.x, other.y + other.h)) {
return true;
}
if (this.Includes(other.x+other.w, other.y + other.h)) {
return true;
}
return this.x == other.x && this.y == other.y && this.w == other.w && this.h == other.h;
}
public bool Includes(double x, double y) {
return (this.x < x && x < this.x + this.w && this.y < y && y < this.y + this.h);
}
public bool Intersect(BaseRect other)
{
return (this.x < other.x + other.w && this.x + this.w > other.x &&
this.y < other.y + other.h && this.y + this.h > other.y);
}
public bool Intersect(BaseRect other)
{
return this.x < other.x + other.w && this.x + this.w > other.x && this.y > other.y + other.h && this.y + this.h < other.y;
}
public bool Intersect(BaseRect other)
{
double thisRight = this.x + this.w;
double thisBottom = this.y + this.h;
double otherRight = other.x + other.w;
double otherBottom = other.y + other.h;
// якщо прямокутники не перетинаються
if (this.x > otherRight || thisRight < other.x || this.y > otherBottom || thisBottom < other.y)
return false;
// якщо прямокутники перетинаються
return true;
}
public bool Includes(double x, double y)
{
return (x >= this.x && x <= this.x + this.w) && (y <= this.y && y >= this.y - this.h);
}
public bool Intersect(BaseRect other)
{
return (this.Includes(other.x, other.y) || this.Includes(other.x, other.y - other.h)
|| this.Includes(other.x + other.w, other.y) || this.Includes(other.x + other.w, other.y - other.h))
|| (other.Includes(this.x, this.y) || other.Includes(this.x, this.y - this.h)
|| other.Includes(this.x + this.w, this.y) || other.Includes(this.x + this.w, this.y - this.h));
}
public bool Intersect(BaseRect other) {
bool xOverlap = (this.x + this.w >= other.x) && (other.x + other.w >= this.x);
bool yOverlap = (this.y + this.h >= other.y) && (other.y + other.h >= this.y);
return xOverlap && yOverlap;
}
public bool Intersect(BaseRect other)
{
return this.x + this.w > other.x && this.x < other.x && this.y + this.h > other.y && this.y < other.y;
}
public bool Intersect(BaseRect b){
double xIntersection = GetSegmentsIntersectionLength(x, x+w, b.x, b.x+b.w);
double yIntersection = GetSegmentsIntersectionLength(x, x+h, b.x, b.x+b.h);
return xIntersection * yIntersection==0.0;
}
double GetSegmentsIntersectionLength(double aLeft, double aRight, double bLeft, double bRight)
{
double left = Math.Max(aLeft, bLeft);
double right = Math.Min(aRight, bRight);
return Math.Max(right - left, 0.0);
}
public bool Intersect(BaseRect other)
{
if (Math.Max(this.x, this.x + w) < Math.Min(other.x, other.x + other.w) || Math.Max(this.y, this.y - h) < Math.Min(other.y, other.y - other.h) || Math.Min(this.y, this.y - h) > Math.Max(other.y, other.y - other.h))
{
return false;
}
else
{
return true;
}
}
public bool Intersect(BaseRect other)
{
if (x == x+w || y == y-h || other.x+other.w == other.x || other.y == other.y-other.h)
return false;
if (this.x > other.x || other.x > x+w)
return false;
if (y-h > other.y || other.y-other.h > this.y)
return false;
return true;
}
public bool Intersect(BaseRect other)
{
double left = Math.Max(this.x,other.x);
double top = Math.Max(this.y, other.y);
double right = Math.Min(this.x + this.w, other.x + this.w);
double bottom = Math.Min(this.y + this.h,other.y + this.h);
return left}
public bool Intersect(BaseRect other)
{
if (other.x > this.x && other.x < this.x + this.w && other.y > this.y && other.y < this.y + this.h)
return true;
else
return false;
}
public bool Intersect(BaseRect other)
{
if (other.x >= x + w || other.x + w <= x)
{
return false;
} else if (other.y - h >= y || other.y <= y - h)
{
return false;
} else
{
return true;
}
}
public bool Intersect(BaseRect other)
{
return this.x < other.x + other.w && this.x + this.w > other.x && this.y < other.y + other.h && this.y + this.h > other.y;
}
public bool Intersect(BaseRect other){
if (this.x <= other.x + other.w &&
this.x + this.w >= other.x &&
this.y <= other.y + other.h &&
this.y + this.h >= other.y)
{
return true;
}
else
{
return false;
}
}
public bool Intersect(BaseRect other)
{
//прямоугольник this
var xA = x;
var yA = y;
var xB = x + w;
var yB = y + h;
//прямоугольник other
var xOtherA = other.x;
var yOtherA = other.y;
var xOtherB = other.x + other.w;
var yOtherB = other.y + other.h;
var left = Math.Max(xA, xOtherA);
var top = Math.Min(yB, yOtherB);
var right = Math.Min(xB, xOtherB);
var bottom = Math.Max(yA, yOtherA);
var width = right - left;
var height = top - bottom;
if (width < 0 || height < 0)
return false;
return true;
}
public bool Intersect(BaseRect other)
{
if ((x > other.x && y < other.y) && (x < other.x + other.w && y > other.y - other.h))
return true;
if ((x > other.x && y - h < other.y) && (x < other.x + other.w && y - h > other.y - other.h))
return true;
if ((x + w > other.x && y < other.y) && (x + w < other.x + other.w && y > other.y - other.h))
return true;
if ((x + w > other.x && y - h < other.y) && (x + w < other.x + other.w && y - h > other.y - other.h))
return true;
else
return false;
}
public bool Intersect(BaseRect other){
if (this.x == other.x || this.y ==other.y || this.h == other.h || this.w == other.w)
{
return false;
}
if (this.x > other.h ||other.x > this.h)
{
return false;
}
if (this.w > other.y || this.w > other.y)
{
return false;
}
return true;
}
public bool Intersect(BaseRect other)
{
return (other.x < x+w) && (other.y < y+h);
}
public bool Intersect(BaseRect other)
{
double left = Math.Max(this.x, other.x);
double right = Math.Min(this.x + this.w, other.x + other.w);
double top = Math.Max(this.y, other.y);
double bottom = Math.Min(this.y + this.h, other.y + other.h);
double width = right - left;
double height = bottom - top;
return width > 0 && height > 0;
}
public bool Intersect(BaseRect other) => this.x < other.x + other.w &&
other.x < this.x + this.w &&
this.y < other.y + other.h &&
other.y < this.y + this.h;
public bool Intersect(BaseRect other) {
if(this.x>other.x && this.x< other.x + other.w){
return true;
}
else{
return false;
}
}
public bool Intersect(BaseRect other){
if(this.x>(other.w+other.x) || other.x>(this.w+this.x)) return false;
if((this.h+this.y)>other.y || (other.h+other.y)>this.y) return false;
return true;
}
public bool Intersect(BaseRect other)
{
bool valueInRange(double value, double min, double max) { return (value >= min) && (value <= max); }
bool xOverlap = valueInRange(this.x, other.x, other.x + other.w) ||
valueInRange(other.x, this.x, this.x + this.w);
bool yOverlap = valueInRange(this.y, other.y, other.y + other.h) ||
valueInRange(other.y, this.y, this.y + this.h);
return xOverlap && yOverlap;
}
public bool Intersect(BaseRect other)
{
return other.x > this.x - other.w
&& other.x < this.x + this.w
&& other.y > this.y - this.h
&& other.y < this.y + other.h;
}
public bool Intersect(BaseRect other)
{
bool intersectX = ((x <= (other.x + other.w)) && (other.x <= (x + w)));
bool intersectY = ((y <= (other.y + other.h)) && (other.y <= (y + h)));
return (intersectX && intersectY);
}
public bool Intersect(BaseRect other)
{
return other.x > x - other.w
&& other.x < x + w
&& other.y > y - h
&& other.y < y + other.h;
}
public bool Intersect(BaseRect other)
{
// экранная система координат
if (
this.x > other.x + other.w || // this справа
other.x > this.x + this.w || // other справа
this.y > other.y + other.h || // this снизу
other.y > this.y + this.h // other снизу
)
{return false;}
else return true;
}
public bool Intersect(BaseRect other) {
return this.x > other.x && this.x < other.x + other.w && this.y > other.y && this.y < other.y+other.h;
}
{
if(((other.x>this.x&&other.x< this.x+this.w)||(other.x+w>this.x&&other.x+w< this.x+this.w))&&((other.y>this.y&&other.y< this.y+this.h)||(other.y+other.h>this.y&&other.y+other.h< this.y+this.w))) return true;
return false;
}
{
return other.x > this.x - other.w
&& other.x < this.x + this.w
&& other.y > this.y - this.h
&& other.y < this.y + other.h;
}
{
return !(this.x + this.w - 1 < other.x ||
this.x > other.x + other.w - 1 ||
this.y > other.y + other.h - 1 ||
this.y + this.h - 1 < other.y
);
}
{
return x >= this.x && x <= this.x + w
&& y >= this.y && y <= this.y + h;
}
public bool Intersect(BaseRect other)
{
return other.Includes(x, y)
|| other.Includes(x + w, y)
|| other.Includes(x, y + h)
|| other.Includes(x + w, y + h);
}
{
double thisSum = (this.x + this.w)*(this.y + this.h);
double otherSum = (other.x + other.w)*(other.y + other.h);
return (thisSum == otherSum);
}
{
double thisRight = this.x + this.w;
double thisBottom = this.y + this.h;
double otherRight = other.x + other.w;
double otherBottom = other.y + other.h;
bool xOverlap = (this.x < other.x && thisRight > other.x) || (this.x >= other.x && this.x < otherRight);
bool yOverlap = (this.y < other.y && thisBottom > other.y) || (this.y >= other.y && this.y < otherBottom);
return xOverlap && yOverlap;
}
return true;
}
{
if (other.x + other.w < x || x + w < other.x)
return false;
if (other.y + other.h < y || y + h < other.y)
return false;
return true;
}
{
if (this.x <= other.x && this.x + this.w >= other.x && this.y >= other.y && this.y - this.h <= other.y)
{
return true;
}
else if ((this.x <= other.x + other.w) && (this.x + this.w >= other.x + other.w) && (this.y >= other.y) && (this.y - this.h <= other.y))
{
return true;
}
else if (this.x <= other.x && this.x + this.w >= other.x && this.y >= other.y - other.h && this.y - this.h <= other.y - other.y)
{
return true;
}
else if (this.x <= other.x + other.w && this.x + this.w >= other.x + other.w && this.y >= other.y -other.h && this.y - this.h <= other.y - other.h)
{
return true;
}
else
{
return false;
}
}
return false;
}
{
return !(x + w < other.x || y < other.y - other.h || x > other.x + other.w || y - h > other.y);
}
{
return this.x < other.x+other.w && other.x < this.x+this.w && this.y < other.y+other.h && other.y < this.y+this.h;
}
return other.x > x - other.w
&& other.x < x + w
&& other.y > y - h
&& other.y < y + other.h;
}
{
double thisX = this.x + this.w;
double thisY = this.y + this.h;
double otherX = other.x + other.w;
double otherY = other.y + other.h;
if (this.x < otherX && thisX > other.x && this.y < otherY && thisY > other.y)
{
return true;
}
else {return false;}
}
return true;
}
{
bool inter_x = Math.Abs((x + w) - (other.x + other.w)) <= (w + other.w);
bool inter_y = Math.Abs((y + h) - (other.y + other.h)) <= (h + other.h);
return inter_x && inter_y;
}
{
double x1 = x + w;
double y1 = y + h;
double x2 = other.x + other.w;
double y2 = other.y + other.h;
if (x > x2 || x1 < other.x || y > y2 || y1 < other.y)
{
return false;
}
return true;
}
{
for(double i1 = this.x; i1 < this.x + this.w; i1++)
{
for(double j1 = this.y; j1 < this.y + this.h; j1++)
{
for(double i2 = other.x; i2 < other.x + other.w; i2++)
{
for(double j2 = other.x; j2 < other.x + other.w; j2++)
if(i1 == i1 && j1 == j2) return true;
}
}
}
return false;
}
{
return (this.x + this.w < other.x || other.x + other.w < this.x) ||
(this.y - this.h > other.y || other.y - other.h > this.y);
}
return (x > this.x & x < this.x + this.w ? true : false & y > this.y & x < this.y+ this.h ? true : false);
}
{
double l = Math.Max(this.x ,other.x);
double r = Math.Max(this.x+this.w , other.x+other.w);
double b = Math.Max(this.y-h,other.y-h);
double t = Math.Max(this.y , other.y);
if (r-l < 0 || t-b < 0)
return false;
else
{
return true;
}
}
double x2 = this.x + this.w;
double y2 = this.y + this.h;
double otherX2 = other.x + other.w;
double otherY2 = other.y + other.h;
return this.x < otherX2 && x2 > other.x && this.y < otherY2 && y2 > other.y;
}
if(x + w < other.x || other.x + other.w < x){
return false;
}
if(y + h < other.y || other.y + other.h < y){
return false;
}
return true;
}
if (this.Includes(other.x, other.y)){
return true;
}
if (this.Includes(other.x+other.w, other.y)) {
return true;
}
if (this.Includes(other.x, other.y + other.h)) {
return true;
}
if (this.Includes(other.x+other.w, other.y + other.h)) {
return true;
}
return this.x == other.x && this.y == other.y && this.w == other.w && this.h == other.h;
}
public bool Includes(double x, double y) {
return (this.x < x && x < this.x + this.w && this.y < y && y < this.y + this.h);
}
{
return (this.x < other.x + other.w && this.x + this.w > other.x &&
this.y < other.y + other.h && this.y + this.h > other.y);
}
{
return this.x < other.x + other.w && this.x + this.w > other.x && this.y > other.y + other.h && this.y + this.h < other.y;
}
{
double thisRight = this.x + this.w;
double thisBottom = this.y + this.h;
double otherRight = other.x + other.w;
double otherBottom = other.y + other.h;
// якщо прямокутники не перетинаються
if (this.x > otherRight || thisRight < other.x || this.y > otherBottom || thisBottom < other.y)
return false;
// якщо прямокутники перетинаються
return true;
}
{
return (x >= this.x && x <= this.x + this.w) && (y <= this.y && y >= this.y - this.h);
}
public bool Intersect(BaseRect other)
{
return (this.Includes(other.x, other.y) || this.Includes(other.x, other.y - other.h)
|| this.Includes(other.x + other.w, other.y) || this.Includes(other.x + other.w, other.y - other.h))
|| (other.Includes(this.x, this.y) || other.Includes(this.x, this.y - this.h)
|| other.Includes(this.x + this.w, this.y) || other.Includes(this.x + this.w, this.y - this.h));
}
bool xOverlap = (this.x + this.w >= other.x) && (other.x + other.w >= this.x);
bool yOverlap = (this.y + this.h >= other.y) && (other.y + other.h >= this.y);
return xOverlap && yOverlap;
}
{
return this.x + this.w > other.x && this.x < other.x && this.y + this.h > other.y && this.y < other.y;
}
double xIntersection = GetSegmentsIntersectionLength(x, x+w, b.x, b.x+b.w);
double yIntersection = GetSegmentsIntersectionLength(x, x+h, b.x, b.x+b.h);
return xIntersection * yIntersection==0.0;
}
double GetSegmentsIntersectionLength(double aLeft, double aRight, double bLeft, double bRight)
{
double left = Math.Max(aLeft, bLeft);
double right = Math.Min(aRight, bRight);
return Math.Max(right - left, 0.0);
}
{
if (Math.Max(this.x, this.x + w) < Math.Min(other.x, other.x + other.w) || Math.Max(this.y, this.y - h) < Math.Min(other.y, other.y - other.h) || Math.Min(this.y, this.y - h) > Math.Max(other.y, other.y - other.h))
{
return false;
}
else
{
return true;
}
}
{
if (x == x+w || y == y-h || other.x+other.w == other.x || other.y == other.y-other.h)
return false;
if (this.x > other.x || other.x > x+w)
return false;
if (y-h > other.y || other.y-other.h > this.y)
return false;
return true;
}
{
double left = Math.Max(this.x,other.x);
double top = Math.Max(this.y, other.y);
double right = Math.Min(this.x + this.w, other.x + this.w);
double bottom = Math.Min(this.y + this.h,other.y + this.h);
return left
{
if (other.x > this.x && other.x < this.x + this.w && other.y > this.y && other.y < this.y + this.h)
return true;
else
return false;
}
{
if (other.x >= x + w || other.x + w <= x)
{
return false;
} else if (other.y - h >= y || other.y <= y - h)
{
return false;
} else
{
return true;
}
}
{
return this.x < other.x + other.w && this.x + this.w > other.x && this.y < other.y + other.h && this.y + this.h > other.y;
}
if (this.x <= other.x + other.w &&
this.x + this.w >= other.x &&
this.y <= other.y + other.h &&
this.y + this.h >= other.y)
{
return true;
}
else
{
return false;
}
}
{
//прямоугольник this
var xA = x;
var yA = y;
var xB = x + w;
var yB = y + h;
//прямоугольник other
var xOtherA = other.x;
var yOtherA = other.y;
var xOtherB = other.x + other.w;
var yOtherB = other.y + other.h;
var left = Math.Max(xA, xOtherA);
var top = Math.Min(yB, yOtherB);
var right = Math.Min(xB, xOtherB);
var bottom = Math.Max(yA, yOtherA);
var width = right - left;
var height = top - bottom;
if (width < 0 || height < 0)
return false;
return true;
}
{
if ((x > other.x && y < other.y) && (x < other.x + other.w && y > other.y - other.h))
return true;
if ((x > other.x && y - h < other.y) && (x < other.x + other.w && y - h > other.y - other.h))
return true;
if ((x + w > other.x && y < other.y) && (x + w < other.x + other.w && y > other.y - other.h))
return true;
if ((x + w > other.x && y - h < other.y) && (x + w < other.x + other.w && y - h > other.y - other.h))
return true;
else
return false;
}
if (this.x == other.x || this.y ==other.y || this.h == other.h || this.w == other.w)
{
return false;
}
if (this.x > other.h ||other.x > this.h)
{
return false;
}
if (this.w > other.y || this.w > other.y)
{
return false;
}
return true;
}
{
return (other.x < x+w) && (other.y < y+h);
}
{
double left = Math.Max(this.x, other.x);
double right = Math.Min(this.x + this.w, other.x + other.w);
double top = Math.Max(this.y, other.y);
double bottom = Math.Min(this.y + this.h, other.y + other.h);
double width = right - left;
double height = bottom - top;
return width > 0 && height > 0;
}
other.x < this.x + this.w &&
this.y < other.y + other.h &&
other.y < this.y + this.h;
if(this.x>other.x && this.x< other.x + other.w){
return true;
}
else{
return false;
}
}
if(this.x>(other.w+other.x) || other.x>(this.w+this.x)) return false;
if((this.h+this.y)>other.y || (other.h+other.y)>this.y) return false;
return true;
}
{
bool valueInRange(double value, double min, double max) { return (value >= min) && (value <= max); }
bool xOverlap = valueInRange(this.x, other.x, other.x + other.w) ||
valueInRange(other.x, this.x, this.x + this.w);
bool yOverlap = valueInRange(this.y, other.y, other.y + other.h) ||
valueInRange(other.y, this.y, this.y + this.h);
return xOverlap && yOverlap;
}
{
return other.x > this.x - other.w
&& other.x < this.x + this.w
&& other.y > this.y - this.h
&& other.y < this.y + other.h;
}
{
bool intersectX = ((x <= (other.x + other.w)) && (other.x <= (x + w)));
bool intersectY = ((y <= (other.y + other.h)) && (other.y <= (y + h)));
return (intersectX && intersectY);
}
{
return other.x > x - other.w
&& other.x < x + w
&& other.y > y - h
&& other.y < y + other.h;
}
{
// экранная система координат
if (
this.x > other.x + other.w || // this справа
other.x > this.x + this.w || // other справа
this.y > other.y + other.h || // this снизу
other.y > this.y + this.h // other снизу
)
{return false;}
else return true;
}
public bool Intersect(BaseRect other) {
return this.x > other.x && this.x < other.x + other.w && this.y > other.y && this.y < other.y+other.h;
}