문제

I have an algorithm where I trace convex polygons from a light source, all contained between 4 walls.This is the algorithm:

Preparation - add all vertices to an array, sorted by their angle from the light source and then add all lines made by all vertices in another array.

Loop all vertices and rotate the ray to their angles Set each vertex to be the nearest point. For each vertex loop all lines and intersect the ray with them, if a line/ray intersection point is closer than the previous nearest point then set this as the nearest point.

This works perfectly except for this case: enter image description here The green lines aren't being considered by the algorithm.How can I make it continue beyond the ends of the polygon?

도움이 되었습니까?

해결책

I don't see any reason why the green lines should be considered! The ray falls on the vertex, which is still part of the solid polygon. It is therefore logical that the ray will not continue further (along the green line). Your algorithm is correct and consistent!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top