intersect(x, y, w = 0, h = 0) {
        if (w == 0 || h == 0) {  // Point-element intersection
            return (x >= this.x - this.width / 2.0) &&
                   (x <= this.x + this.width / 2.0) &&
                   (y >= this.y - this.height / 2.0) &&
                   (y <= this.y + this.height / 2.0);
        } else {                 // Box-element intersection
            return (x <= this.x + this.width / 2.0) &&
                    (x + w >= this.x - this.width / 2.0) &&
                    (y <= this.y + this.height / 2.0) &&
                    (y + h >= this.y - this.height / 2.0);
        }
    }
// General bounding-box intersection function. Returns true iff point or rectangle intersect element.
General bounding-box intersection function. Returns true iff point or rectangle intersect element.
General bounding - box intersection function . Returns true iff point or rectangle intersect element .
intersect(x, y, w = 0, h = 0) {
        if (w == 0 || h == 0) {  
            return (x >= this.x - this.width / 2.0) &&
                   (x <= this.x + this.width / 2.0) &&
                   (y >= this.y - this.height / 2.0) &&
                   (y <= this.y + this.height / 2.0);
        } else {                 
            return (x <= this.x + this.width / 2.0) &&
                    (x + w >= this.x - this.width / 2.0) &&
                    (y <= this.y + this.height / 2.0) &&
                    (y + h >= this.y - this.height / 2.0);
        }
    }
intersect ( x , y , w = 0 , h = 0 ) { if ( w == 0 || h == 0 ) { return ( x >= this . x - this . width / 2.0 ) && ( x <= this . x + this . width / 2.0 ) && ( y >= this . y - this . height / 2.0 ) && ( y <= this . y + this . height / 2.0 ) ; } else { return ( x <= this . x + this . width / 2.0 ) && ( x + w >= this . x - this . width / 2.0 ) && ( y <= this . y + this . height / 2.0 ) && ( y + h >= this . y - this . height / 2.0 ) ; } }
General bounding-box intersection function.
General bounding - box intersection function .
// Point-element intersection // Box-element intersection