draw a horizontal line from the point to infinity so as to guarantee that it clears the polygon.

If the horizontal line intersects the polygon in an odd number of points, then it is inside.

**Goal**
I want to determine if a test point is within a defined quadrilateral. I'm probably going to implement the solution in Matlab so I only need pseudo-code.
**Inputs**
Corners of quadrilateral : (x1,y1) (x2,y2) (x3,y3) (x4,y4)
Test point : (xt, yt)
**Output**
1 - If within quadrilateral
0 - Otherwise
**Update**
It was pointed out that identifying the vertices of the quadrilateral is not enough to uniquely identify it. You can assume that the order of the points determines the sides of the quadrilateral (point 1 connects 2, 2 connects to 3, 3 connects to 4, 4 connects to 1)

Follow
•
1

Add comment

More

Report

draw a horizontal line from the point to infinity so as to guarantee that it clears the polygon.

If the horizontal line intersects the polygon in an odd number of points, then it is inside.

Ask a question for free

Get a free answer to a quick problem.

Most questions answered within 4 hours.

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.