Q:

Write a JavaScript program to check whether a point lies strictly inside a given circle

0

 Write a JavaScript program to check whether a point lies strictly inside a given circle. 
Input:
Center of the circle (x, y)
Radius of circle: r

Point inside a circle (a, b)

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

function check_a_point(a, b, x, y, r) {
    var dist_points = (a - x) * (a - x) + (b - y) * (b - y);
    r *= r;
    if (dist_points < r) {
        return true;
    }
    return false;
}

console.log(check_a_point(0, 0, 2, 4, 6));
console.log(check_a_point(0, 0, 6, 8, 6));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now