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

  • برمجة جافاسكربت java script
  • برمجة

 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)

الأجوبة

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));
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...