# Will points on path with width intersect

I want to be able to check if a list of points will hit a screwed rectangle (rhombus i think).

I start out with 2 point P and T, i want to create a rectangle between the 2 points. I have used https://stackoverflow.com/questions/7854043/drawing-rectangle-between-two-points-with-arbitrary-width to do this. This gives me 4 points A, B, C and D of the new rectangle.

I then want to check if the point M is withing this rectangle. The two black dots are my points P and T, the black box is the rectangle i want to generate between the two dots, being X wide. I then want to test if the red dots are withing the black box.

• So is there a question you wanted to ask?
– user35344
May 9, 2016 at 5:02
• @Tyyppi_77 "I then want to check if the point M is withing this rectangle." But see my updated question May 9, 2016 at 5:39

The idea is, you cast a ray (assume a line) from your point to either the left or the right. Then for each side of your polygon, you test whether the ray intersects it, and if it does, you add 1 to a counter. At last, if the number of times the ray intersected with a side is odd (that is if counter % 2 == 1), your point lies inside the polygon.