Given a parabola with vertex (h, k), and , the distance between focus and vertex. The task is to determine if the point (x, y) is inside, outside or on the parabola.
Input: h = 100, k = 500, x = 20, y = 10, a = 4 Output: Outside Input: h = 0, k = 0, x = 2, y = 1, a = 4 Output: Inside
Approach: It is very simple, we have to just solve the equation for point (x, y):
(y-k)^2 = 4a(x-h)
or, (y-k)^2 – 4a(x-h) = 0
After solving, if the result comes less than 0 then the point lies within, else if it comes exact 0 then the point lies on the parabola, and if the result is greater than 0 unsatisfied the point lies outside of the parabola.
Here we are taking a parabola whose axis of symmetry is y = k, although the approach is applicable for any parabola.
Below is the implementation of 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.
- Check if a point is inside, outside or on the ellipse
- Check whether a given point lies on or inside the rectangle | Set 3
- Check whether a point lies inside a sphere or not
- Check whether a given point lies inside a rectangle or not
- Check whether a given point lies inside a triangle or not
- Check if a point lies on or inside a rectangle | Set-2
- How to check if a given point lies inside or outside a polygon?
- Check if the given point lies inside given N points of a Convex Polygon
- Satisfy the parabola when point (A, B) and the equation is given
- Triangle with no point inside
- Find a point that lies inside exactly K given squares
- Find if a point lies inside a Circle
- Find if a point lies inside, outside or on the circumcircle of three points A, B, C
- Find intersection point of lines inside a section
- Find minimum radius such that atleast k point lie inside the circle
- 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 whether given floating point number is even or odd
- Check if any K ranges overlap at any point
- Check if any point overlaps the given Circle and Rectangle
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.