简体   繁体   中英

Drawing no intersected polygon with dragging vertexes

I'm trying to draw a polygon without intersecting.

Below is good example which I want to.

在此处输入图像描述

Bad example what I want to prevent.

在此处输入图像描述

If I choose red dot one, then what algorithm I can apply to prevent the intersecting sides of the polygon?

Technical answer:

The moving point must belong to the visibility zones of its two neighbors (ignoring the two adjoining edges).

在此处输入图像描述

You can construct these two zones and their intersection once for all, then constrain the cursor to remain in the intersection. This can be made efficiently in time O(Log(N)) per query, after some preprocessing. But this is quite complex and not worth the effort.

在此处输入图像描述

Practical answer:

Simply check that the two edges from the moving point do not intersect the remaining edges.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM