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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if a circle lies inside another circle or not
- Find a point that lies inside exactly K given squares
- Check if a given circle lies completely inside the ring formed by two concentric circles
- 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 the given point lies inside given N points of a Convex Polygon
- Count of integral coordinates that lies inside a Square
- Choose points from two ranges such that no point lies in both the ranges
- 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
- Equation of circle when three points on the circle are given
- Angle subtended by the chord to center of the circle when the angle subtended by the another equal chord of a congruent circle is given
- Area of the circle that has a square and a circle inscribed in it
- Shortest distance between a point and a circle
- Check if any point overlaps the given Circle and Rectangle
- Find the GCD that lies in given range
- Find two distinct numbers such that their LCM lies in given range
- Rotation of a point about another point in C++