Given a circle (coordinates of centre and radius) and a point (coordinate), find if the point lies inside or on the circle, or not.
Input: x = 4, y = 4 // Given Point circle_x = 1, circle_y = 1, rad = 6; // Circle Output: Inside Input: x = 3, y = 3 // Given Point circle_x = 0, circle_y = 1, rad = 2; // Circle Output: Outside
We strongly recommend you to minimize your browser and try this yourself first.
The idea is compute distance of point from center. If distance is less than or equal to radius. the point is inside, else outside.
Below is the implementation of above idea.
Thanks to Utkarsh Trivedi for suggesting above solution
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Find a point that lies inside exactly K given squares
- Check if a circle lies inside another circle or not
- Check whether a given point lies inside a triangle or not
- How to check if a given point lies inside or outside a polygon?
- Check whether a given point lies on or inside the rectangle | Set 3
- Check if a given circle lies completely inside the ring formed by two concentric circles
- Check whether the point (x, y) lies on a given line
- Check if a point is inside, outside or on the ellipse
- Check if a point is inside, outside or on the parabola
- Shortest distance between a point and a circle
- Choose points from two ranges such that no point lies in both the ranges
- Find the GCD that lies in given range
- Find the number of squares inside the given square grid
- Find the other-end coordinates of diameter in a circle
- Program to find area of a circle