Get the Euclidean distance between the edges of two shapes - Node.js Geometry

Node.js examples for Geometry:Distance

Description

Get the Euclidean distance between the edges of two shapes

Demo Code


// get the Euclidean distance between the edges of two shapes
exports.getDistance = function (p1, p2) {
    return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)) - p1.radius - p2.radius;
};

Related Tutorials