Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Is the point is out of quadrilateral

Status
Not open for further replies.

mohanchandra

New Member
how to check whether the point is out of quadrilateral or not ?

i have quadrilateral. its points are (x1,y1),(x2,y2),(x3,y3),(x4,y4).
how do u check the point (x5,y5) is out of quadrilateral or not
 
Last edited:
Make four equations- one representing each side of the shape from your 4 points (the equation for a line ). Then plug in the 5th point into the equation to check if the point is within the bounds of the lines represented by each equation (ie. between the left and right sides and between the top and bottom sides) using less/greater than.
 
Last edited:
i have quadrilateral. its points are (x1,y1),(x2,y2),(x3,y3),(x4,y4).
how do u check the point (x5,y5) is out of quadrilateral or not

Find a diagonal (trivial if your quadrilateral is convex, otherwise needs care) and reduce problem to two triangles. There are fast triangle hit test algorithms out there (use google), I think using barycentric coordinates is one of the best.
 
I can tell you of a method that will not work in all cases, and specify the cases in which it will not work. This method involves comparing all of the x and y values of the quadrilateral – in such a way that it is checked if there are any x values less than the other x values, any x values greater than the other x values, any y values less than the other y values, and any y values greater than the other y values. This should give you four values, two x and two y. Lets call them x6, x7, y6, and y7. The two x values x6 and x7 define a range that the x value x5 of the point in question (x5, y5) might be inside of or outside of. The two y values y6 and y7 also define a range that the y value y5 of the point in question (x5, y5) might be inside of our outside of. This range – of x and y values – x6, x7, y6, and y7, can be used to define horizontal and vertical lines that intersect to define a rectangle. By horizontal and vertical I mean parallel with any axes that you may decide to use which appear to be an x axis and a y axis. These horizontal and vertical lines are the sides, roof, and floor of the rectangle described. The sides of the rectangle will therefore intersect these four points x6, x7, y6, and y7 – unless your points are 4 coincident points – all of which define the same point, or four points on a line segment. x6, x7, y6, and y7 may be used to describe a rectangle or square in the manner described above. I’ll just assume that it is a rectangle. (x5, y5) can be in any of three locations – only inside of the quadrilateral, inside both the rectangle and the quadrilateral, or outside of the rectangle. If the point is outside of the rectangle then it is also outside of the quadrilateral. This is the easiest method that I could think of to define a rectangle enclosing or being (x1, y1), (x2, y2), (x3, y3), (x4, y4). If – with or without drawing these figures, it is found that x5 is not between the minimum and maximum numerical x values that you determined from the quadrilateral x6 and x7…or – if it is found that y5 is not between the minimum and maximum y values that you determined from the quadrilateral y6 and y7, then the point is outside the rectangle and therefore outside of the quadrilateral. The point does not have to be outside of both the x range and y range – only one of these ranges. Even if it is found that (x5, y5) is inside of the rectangle, (x5, y5) may still in important cases be outside of the quadrilateral. Therefore, this method may only be useful when there is a high probability that (x5, y5) is outside of (x1, y1), (x2, y2), (x3, y3), (x4, y4) – or a low probability that it is inside. I’m not sure if this probability would be dependent upon the shape of the quadrilateral from which the above description of a rectangle has been made.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top