# Smoothing curve with series of Line Segments

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

## Recommended Posts

I am starting to write a game similar to Flight Control for the iPhone.

The user draws a line, I am storing points at intervals as the user drags the pointer around the screen. The problem at this point is that points are not all equidistant and the line is not smooth. What I want to do is then go and draw shorter line segments of equal length smoothing the sharper corners (but no curves). This would simplify moving the sprite along the path etc.

The basic problem is, if I have a 90 degree or smaller angle, how do I figure out given a fixed length for the line segments, where the end points of the line segments would be to smooth the sharp corner.

Does anybody know if there is any sample code for a similar problem before I start trying to write this myself? (I don't think this is how the Flight Control game works but it's a solution I think would work for me as I am writing this using the Corona SDK which has no Bezier curve library.

Many Thanks

##### Share on other sites
Quote:
 Original post by mthickeI am starting to write a game similar to Flight Control for the iPhone.The user draws a line, I am storing points at intervals as the user drags the pointer around the screen. The problem at this point is that points are not all equidistant and the line is not smooth. What I want to do is then go and draw shorter line segments of equal length smoothing the sharper corners (but no curves). This would simplify moving the sprite along the path etc.The basic problem is, if I have a 90 degree or smaller angle, how do I figure out given a fixed length for the line segments, where the end points of the line segments would be to smooth the sharp corner. Does anybody know if there is any sample code for a similar problem before I start trying to write this myself? (I don't think this is how the Flight Control game works but it's a solution I think would work for me as I am writing this using the Corona SDK which has no Bezier curve library.Many Thanks

Why not go at it from a different direction? Instead of creating a new line at each interval of time, create a new line when the drawing cursor has covered the distance you want to use.

##### Share on other sites
Consider fitting a curve to the input points and then sampling the curve to obtain points that are uniformly spaced along the curve. "Curve fitting" and "reparameterization by arc length" might be useful in an online search.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634087
• Total Posts
3015446
×