"use strict";
cc._RF.push(module, '997fc58y39OFLflh6T58fZD', 'lq_math_util');
// Script/lq_base/util/lq_math_util.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LQMathUtil = void 0;
var LQMathUtil = /** @class */ (function () {
    function LQMathUtil() {
    }
    LQMathUtil.random = function (min, max) {
        if (min === max) {
            return min;
        }
        else if (min < max) {
            return Math.random() * (max - min) + min;
        }
        else {
            return Math.random() * (min - max) + max;
        }
    };
    LQMathUtil.random_int = function (min, max) {
        return Math.floor(this.random(min, max));
    };
    LQMathUtil.get_radians = function (pos, target_pos) {
        var r = Math.atan2(target_pos.y - pos.y, target_pos.x - pos.x);
        return r > 0 ? r : r + 6.28;
    };
    LQMathUtil.intersects_rect = function (r1, r2) {
        return Math.abs(r1.x - r2.x) < r1.half_width + r2.half_width && Math.abs(r1.y - r2.y) < r1.half_height + r2.half_height;
    };
    LQMathUtil.intersects_point_rect = function (p, r) {
        return (p.x > r.x - r.width * 0.5) && (p.x < r.x + r.width * 0.5) && (p.y > r.y - r.height * 0.5) && (p.y < r.y + r.height * 0.5);
    };
    LQMathUtil.intersects_point_circle = function (p1, p2, r) {
        return p1.sub(p2).magSqr() < r * r;
    };
    LQMathUtil.intersects_circle = function (p1, r1, p2, r2) {
        return p1.sub(p2).mag() < r1 + r2;
    };
    LQMathUtil.intersects_circle_rect = function (p, r, rect) {
        var relative_x = p.x - rect.x;
        var relative_y = p.y - rect.y;
        var dx = Math.min(relative_x, rect.half_width);
        var dx1 = Math.max(dx, -rect.half_width);
        var dy = Math.min(relative_y, rect.half_height);
        var dy1 = Math.max(dy, -rect.half_height);
        return (dx1 - relative_x) * (dx1 - relative_x) + (dy1 - relative_y) * (dy1 - relative_y) <= r * r;
    };
    return LQMathUtil;
}());
exports.LQMathUtil = LQMathUtil;

cc._RF.pop();