Jump to content
  • Advertisement
Sign in to follow this  
andy82

Polygon border

This topic is 4322 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, does someone know what is the usual way to create a border of size "bordersize" around a polygon? For example, I want to calculate the black polygon from the vertices of the red polygon: I tried to scale the red arrow polygon by 2*bordersize in both x/y directions but that doesn't do the job for most polygons. Thanks for your help. Andy

Share this post


Link to post
Share on other sites
Advertisement
Ok, but how do I calculate the normals for my polygon? Sorry, I'm not so much into mathematics... I try to look it up using google but it all seems to be working with 3D vectors but my polygon is just 2D with only x,y vertices.

Share this post


Link to post
Share on other sites
The normal of an edge is orthogonal to that edge and pointing out from the polygon's interior. The normal of a vertex is the normalized average of the normals of its two adjoining edges.

This approach, however, is imprecise (the border will not be perfect). You may need to compute a per-vertex vector that is not the normal, but rather a vector with properties similar to those of the normal, which determines the intersection of the edges of the border.

Share this post


Link to post
Share on other sites
Ok, but how do I calculate the normal from a vertex? From the snippet posted above (newVertex = oldVertex + oldNormal * bordersize) I'd assume that the normal is always 1,-1 or 0. But how do I calculate it? I guess the vertices surrounding the vertex the normal of which I want to calculate have to be taken into account, too, but how?

Btw: I do not need the perfect algorithm because I'm only doing this with simple forms like the arrow above.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!