bool isIntersectingPoint p Side e 判断射线和边是否相交 if py estarty && py eendy py estarty && py eendy 如果点在边的上方或下方则不相交 return false; if isParalleleendy - estarty eendx - estartx 如果边平行
This function takes in a point p and a side e (represented by its two endpoints) and checks if the ray starting from p in the positive x direction intersects with e.
The function first checks if the point is above or below the side. If it is, then the ray cannot intersect with the side and the function returns false.
Next, the function checks if the side is parallel to the x-axis. If it is, then the ray cannot intersect with the side and the function returns false.
If the point is not above or below the side and the side is not parallel to the x-axis, then the function calculates the x-coordinate of the intersection point between the ray and the side using the equation of a line. If this x-coordinate is greater than the x-coordinate of the point p, then the ray intersects with the side and the function returns true. Otherwise, the ray does not intersect with the side and the function returns false
原文地址: https://www.cveoy.top/t/topic/fjuM 著作权归作者所有。请勿转载和采集!