PDA

View Full Version : Generating a rounded 2D profile of points

_new_horizon
01-16-2006, 07:39 AM
Hi,

Does anyone know the algorithm for producing a string of N vertices for these 2D profiles, based on the parameter value between 0 and 1.0 as shown? Or alternatively, a function to change the positions of an existing series of vertices similarly?

http://img.photobucket.com/albums/v614/tycho61uk/Curves.gif

I just need the vertices - no lines on polygons.

Relic
01-16-2006, 08:23 AM
Two pairs of three points in the lefthand image describe the two corners (counting from 0 at point 1 and 3) and the value 0.0 to 1.0 is the normalized radius of the circle at each corner point in lengths of the respective adjacent lines. (Confused?)
That's able to do this rounded rectangle thing in the middle.

Could also be quadratic splines, but then the middle picture would be more difficult and needed weights.

_new_horizon
01-16-2006, 10:36 AM
Sorry Relic, I don't follow you :confused:

This should be possible without the use of control points or splines.

Alternatively, I need generate only the top quadrant and mirror it to create the bottom.

01-16-2006, 10:53 AM
Have you looked at subdivision surfaces (Loop subdivision, for example)? You can fix the mid vertex in place, for instance, so that only the corners are "smoothed". This is usually presented in the context of generic 3D meshes, but it will work in 2D too (greatly simplified). This maybe a bit much for your needs, but it's definitely worth looking at.

I think maybe that is more or less what Relic was getting at.

Cheers,

:)

_new_horizon
01-16-2006, 12:33 PM
Thanks, but again I'm sure there is a simpler way ;)

01-16-2006, 03:28 PM
Actually, after reading Relic's post again, his approach is very simple indeed. Just look at geometry of the situation: you have 2, 1/4 circles, each centered 1 radius distant from their respective tangent edges. Using this simple relationship, you could adjust your vertex positions to satisfy the radius constraint for each point on a 1/4 circle.

Nice, and simple too.

But don't let the papers scare you, the 2D counterparts of subdivision surfaces are trivial to implement.

Cheers,

:)

Relic
01-17-2006, 12:28 AM
Yes, that's what I meant. :)

_new_horizon
01-17-2006, 03:14 AM
Can you post some pseudo code? :p