Frage

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?

War es hilfreich?

Lösung

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!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top