Men的博客

欢迎光临!

0%

bound是否交叉叠盖

/**
 * 是否交叉叠盖
 * @param {Bound} bound - 交叉叠盖检测对象
 * @return {boolean} 是否交叉叠盖
 */
intersect(bound: Bound) {
    return (bound.xmax >= this._xmin) && (bound.xmin <= this._xmax) && (bound.ymax >= this._ymin) && (bound.ymin <= this._ymax);
}

bound的缩放

/**
 * 缩放整个边界
 * @param {number} s - 缩放倍数
 */
scale(s: number) {
    this._xmin = this._xmin - (s - 1) * (this._xmax - this._xmin)/2;
    this._xmax = this._xmax + (s - 1) * (this._xmax - this._xmin)/2;
    this._ymin = this._ymin - (s - 1) * (this._ymax - this._ymin)/2;
    this._ymax = this._ymax + (s - 1) * (this._ymax - this._ymin)/2;
}