• Advertisement
Sign in to follow this  

Smoothing curve with series of Line Segments

This topic is 2652 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

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by mthicke
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

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 this post


Link to post
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.

Share this post


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

  • Advertisement