Current location - Training Enrollment Network - Mathematics courses - Ray casting algorithm (how to calculate whether the coordinate points are in polygons)
Ray casting algorithm (how to calculate whether the coordinate points are in polygons)
Starting from a point, project a directional, directional, directional and horizontal ray. How many points intersect the edges of a polygon? Odd numbers indicate that they are in the diagram, and even numbers indicate that they are out of the diagram.

Let the point to be judged be (x, y) and the line segment point be (x 1, y 1)(x2, y2).

The company above is the abscissa of the intersection. If the abscissa of the intersection point is greater than the point to be calculated, there is an intersection point. Loop each edge continuously, and finally calculate the intersection number. There is a trigonometric function in the diagram.

Problem, no matter how bad math is, it can also be calculated with a similar triangle in junior high school.