smooth curve from a straight line

Hi,
I’m trying to create a smooth curved line for an object to move along.
I can create a straight line by grabbing the position of the touched object and the position where the touch ends. What I’d like to be able to do though is to “smooth” the initial sharp angle and have a gentle curved approach.

Example: http://imageshack.us/photo/my-images/819/curvedlines.png
(Image on the left is how I currently move objects, image on the right is how I’d like to move objects).

If I had additional points on the angled line I could then use those points as the start and end points of a bezier curve.

Does anyone know how I could add those points? I’m assuming it’ll be some triangle cos/sine/whatever maths approach but I can’t get my head around it.

Any ideas? [import]uid: 27215 topic_id: 15599 reply_id: 315599[/import]

I added a curve drawing algorithm to the code exchange.

http://developer.anscamobile.com/code/curve-fitting-catmull-spline [import]uid: 5354 topic_id: 15599 reply_id: 57608[/import]

Thanks Matthew,
I played with that code and while it does create a curve it’s along the horiontal start and end points rather then the angled line.

Example: http://imageshack.us/photo/my-images/14/catmullline.png/

I *think* the code would work like I want IF I could add additional points to my current line? [import]uid: 27215 topic_id: 15599 reply_id: 57611[/import]

You need more points closer together to get tighter curves around an individual point.

You would need to trace backward from the corner point a few pixels and also forward and actually ignore the corner point after that.
[import]uid: 5354 topic_id: 15599 reply_id: 57614[/import]

Yeah, that’s what I figured, I just don’t know how to find those points.

For instance, I have a starting point (say, the x,y position of the touched object) and I know the angle based on when the touch was completed, I just don’t know how to find the position “x” pixels further away the initial starting point at the same angle.

Any ideas?

EDIT: Might have stumbled onto something with polar coordinates. [import]uid: 27215 topic_id: 15599 reply_id: 57774[/import]