Given an ellipse centered at (h, k), with semi-major axis a, semi-minor axis b, both aligned with the Cartesian plane. The task is to determine if the point (x, y) is within the area bounded by the ellipse.
Input: h = 0, k = 0, x = 2, y = 1, a = 4, b = 5 Output: Inside Input: h = 1, k = 2, x = 200, y = 100, a = 6, b = 5 Output: Outside
Approach: We have to solve the equation of ellipse for the given point (x, y),
(x-h)^2/a^2 + (y-k)^2/b^2 <= 1
If in the inequation, results comes less than 1 then the point lies within, else if it comes exact 1 then the point lies on the ellipse, and if the inequation is unsatisfied then point lies outside of the ellipse.
Below is the implementation of the above approach:
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.
- How to check if a given point lies inside or outside a polygon?
- Check if a point is inside, outside or on the parabola
- Find if a point lies inside, outside or on the circumcircle of three points A, B, C
- Check whether a given point lies inside a triangle or not
- Check whether a given point lies inside a rectangle or not
- Check whether a point lies inside a sphere or not
- Check if a point lies on or inside a rectangle | Set-2
- 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
- Triangle with no point inside
- Find if a point lies inside a Circle
- Find minimum radius such that atleast k point lie inside the circle
- Find intersection point of lines inside a section
- Find a point that lies inside exactly K given squares
- Rotation of a point about another point in C++
- Reflection of a point at 180 degree rotation of another point
- Check if a given circle lies completely inside the ring formed by two concentric circles
- Check if a circle lies inside another circle or not
- Area of a triangle inscribed in a rectangle which is inscribed in an ellipse
- Program to find the Area of an Ellipse
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.