# Path Smoothing

## Recommended Posts

I have a set of 2D points (x,y), that forms a staircase function that looks like this (with a point * at each change of direction): .................................. ...................*----*...... ...................|.............. ...................|.............. ............*----*........... ............|................... ............|................... .....*----*.................... .................................. I want to be able to create a path that smoothens the above path instead of having the "staircase" effect (without reinventing the wheel). What is the best way to do this?? Isn't there a well-known algorithm for doing this? Thanks!

##### Share on other sites
For each vertex, take a weighted average of it and its nearby vertices and set the average as the new value. It's like applying a blur to the positions of the vertices.

##### Share on other sites
Gotcha. Like a gaussian blur.

This would also work too I think:

##### Share on other sites
Quote:
 Original post by Gf11speedI want to be able to create a path that smoothens the above path instead of having the "staircase" effect (without reinventing the wheel). What is the best way to do this?? Isn't there a well-known algorithm for doing this? Thanks!

The ideal answer depends on what you're looking for... but assuming that you wish to constrain the path at the end points, then a Catmull-Rom spline with the waypoints as knots will give you a smooth curve with desirable continuity results.

Cheers,

Timkin

##### Share on other sites
Or, maybe a B-spline. The catmull-rom becomes an nth-order curve (for n control points). A B-spline is a moving cubic curve.

(Am I way off? - don't hold me to this)

##### Share on other sites
Catmull-Rom splines only need the two points surrounding the points you are interpolating between.

Check out this page http://www.cubic.org/docs/hermite.htm for a nice overview of using splines for interpolation.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628282
• Total Posts
2981805

• 9
• 10
• 11
• 17
• 14