//

import { aabb2_signed_distance_sqr_to_point } from "./aabb2_signed_distance_sqr_to_point.js";

/**
 * Compute squared distance to point, value is negative if the point is inside the box
 * @param {number} x0
 * @param {number} y0
 * @param {number} x1
 * @param {number} y1
 * @param {number} point_x
 * @param {number} point_y
 * @returns {number}
 */
export function aabb2_signed_distance_to_point(
    x0, y0,
    x1, y1,
    point_x, point_y
) {
    const sqr = aabb2_signed_distance_sqr_to_point(x0, y0, x1, y1, point_x, point_y);

    if (sqr < 0) {
        return -Math.sqrt(-sqr);
    } else {
        return Math.sqrt(sqr);
    }
}
