Jump to content
  • Advertisement
Sign in to follow this  
Wahooney

Polygon ribbons, again...

This topic is 4098 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 everyone, I need to create a constant-width polygon ribbon from an array of 2D points with either open or closed ends, I have tried two methods with varying results. Neither are incredibly fast or particularly tidy. One relies heavily on trig (a lot of vectors & atan) the other works with offsetting the lines between the points, along each lines normal, and getting the intersections between lines with common vertices... it's faster than trig, but only just. Does anyone know where I can find a good reference or tutorial or even just a method that I can explore? (Googling hasn't helped me thus far, since it seems that not many people call them ribbons :P) Thanks guys and gals.

Share this post


Link to post
Share on other sites
Advertisement
The first step is to compute the bissector of the angle between two consecutive segments. This is done by adding two vectors of the same length, one from each segment (either two segment normals pointing to the same side, or two segment directions one of which is reversed).

Then, you select the correct length by scaling the bissector by dot(bissector,normal) times half the width of your ribbon. Then, you add and substract the bissector to the endpoint shared by the two segments to get the additional points.

That's three vector adds, one dot product, one scaling.

Share this post


Link to post
Share on other sites
All the normal placements of the new points are correct, but their distance from the original polygon aren't constant, that is, they don't give a constand line width.

You say that I must get dot(bisector, normal), which normal must I use?

I tried both the segment normals and the normal I had to invert. But all three cases have the bisector length tend to zero as the two segments become close to being a straight line.

Share this post


Link to post
Share on other sites
Okay, it seems that I have it sussed, I was using the segment vectors to do all my calculations, now I'm using the normals to the segments and it seems to work perfectly! I just have to add exceptions to open edges and I'm done!

ToohrVyk, you kick ass! Thanks alot! :D

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!